
Re: PLEASE HELP! Programming format thing.
So first I formatted the code so that its easy to understand what is happening.
 |  |  |
 | Code: task main() { repeat(forever) { turnFlashlightOn(flashlight, 127); setServo(servo2, 60); setServo(servo3, -10); waitInMilliseconds(2000); setServo(servo3, 30); waitInMilliseconds(190); { if (SensorValue[lightsensor] >500) { if (SensorValue[lightsensor] <700) {setServo(servo, -90); waitInMilliseconds(500); setServo(servo, -10);} else { setServo(servo, 90); waitInMilliseconds(500); setServo(servo, -10); } { if (SensorValue[linefollower] >500) { if (SensorValue[linefollower] <900) { setServo(servo2, 120); waitInMilliseconds(500); setServo(servo2, 60);} else { setServo(servo2, -90); waitInMilliseconds(500); setServo(servo2, 60); } } } } } } } |  |
 |  |  |
The first if statement opens a bracket that never closes until the end of the program. This means all the code contained within the brackets will only run if the set of criteria is true in the if statement.
I am not certain exactly what you are trying to do as part of each conditional statement but it would appear that you want both if statements to close here rather than just one of them close.
The same would be true for
Right now the compiler doesn't know when you want to do each action. If you write out in words how you expect the robot to react to each set of criteria I can try to show you an example of how to write that code but for now just make sure all your if statements only contain the code that depends on if it is true.