Quote:
Originally posted by Marc P.
if var=127 then pwm1=127, if var=254 then pwm1=254
|
Unfortunately, this type of syntax does not work. The only thing after the "then" can be a label to go to if the condition is true. For example:
if (sensor1<127) then dontZeroPWM1
PWM1=127
dontZeroPWM1:
With this code, anytime sensor1 is greater than or equal to 127, PWM1 will be set to 127. When sensor1 is less than 127, the condition is true and the code skips the line that would normally set PWM1.
This is by far one of the most confusing parts of PBASIC and is the reason why many times you will find yourself writing "if not" instead of just plain "if." Once you are able to think of "if" statements as being used to
skip portions of code, everything becomes much easier.