task main() { int light1, light2, cutoff1, cutoff2, base1 = 0, base2 = 0, current, next; float angle, angleplus; angleplus = 5.625; angle = 0; current = 0; while(true) { next = 0; base1 = 0; base2 = 0; light1 = SensorValue[S1]; light2 = SensorValue[S2]; cutoff1 = 690; cutoff2 = 700; if(light1 > cutoff1) base1 = 1; if(light2 > cutoff2) base2 = 1; //nxtDisplayCenteredTextLine(1, "S1Value: %d", base1); //nxtDisplayCenteredTextLine(2, "S2Value: %d", base2); if (base1 == 0 && base2 == 0 ) {next = 1;} else if (base1 == 0 && base2 == 1 ) {next = 2;} else if (base1 == 1 && base2 == 1 ) {next = 3;} else if (base1 == 1 && base2 == 0 ) {next = 4;} else {} //nxtDisplayCenteredTextLine(3, "current: %d", current); //nxtDisplayCenteredTextLine(4, "next: %d", next); if (current == 0) {current = next;} else { if( current != next ){ if (current == 1 && next == 2 ) angle = angle + angleplus; if (current == 1 && next == 3 ) angle = angle; if (current == 1 && next == 4 ) angle = angle - angleplus; if (current == 2 && next == 1 ) angle = angle - angleplus; if (current == 2 && next == 3 ) angle = angle + angleplus; if (current == 2 && next == 4 ) angle = angle; if (current == 3 && next == 1 ) angle = angle; if (current == 3 && next == 2 ) angle = angle - angleplus; if (current == 3 && next == 4 ) angle = angle + angleplus; if (current == 4 && next == 1 ) angle = angle + angleplus; if (current == 4 && next == 2 ) angle = angle; if (current == 4 && next == 3 ) angle = angle - angleplus; } current = next; } nxtDisplayCenteredTextLine(1, "angle: %d", angle); wait1Msec(10); } }