Shop OBEX P1 Docs P2 Docs Learn Events
if then else driving me crazy — Parallax Forums

if then else driving me crazy

power_speedpower_speed Posts: 5
edited 2006-08-25 19:45 in BASIC Stamp
I am writing a motor control program that will sense speed and bring output pins high for a variable amount of time to adjust for speed slow down or speed up.

The compiler keeps giving me an error saying "expected end of line or ':' ".
I have tried everything I can find to think of, however I cannot seem to resolve this error.

I have attached the program.
Thanks to anybody who can help!

Comments

  • Lee HarkerLee Harker Posts: 104
    edited 2006-08-25 18:17
    The problem is that in the else statement you used another conditional. If you get to the else statement, it is because the previous conditionals were not met. Remove that part and it compiles fine.

    Lee
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-25 18:23
    power_speed -

    I suspect the following is what you really want in there:

    IF (pulse1 < 30) THEN ' for 2000 rpms the time for one revolution is 30 ms
    PULSOUT 1, 3
    ELSEIF (pulse1 > 30) THEN
    PULSOUT 1, 7
    ELSE
    PULSOUT 1, 5
    ENDIF

    The third conditional is superfluous to the logic. If pulse1 was neither higher nor lower than 30 it MUST be EQUAL to 30!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • power_speedpower_speed Posts: 5
    edited 2006-08-25 19:45
    Thanks That worked nicley. I only put it the way I had it, because of what I read in the files that came with the program.
Sign In or Register to comment.