I’m a photographer and have been using servos to remotely control cameras for years, last year I was using a BS2, but just recently changed to a BasicATOM Pro 28 for a new project.
I’m using 8.0.1.7 for programming
The IF ELSEIF dosen’t seem to work the way it should ?? in the following battery monitoring code all works like it should except the ELSEIF. the compiler error is “Unexpected token after ELSEIF command”
I have commented the multiple iterations of IF ENDIF out (They work fine and left in the ELSEIF 's in the following code
may seem trivial but I’m using a 10 segment LED array to show battery condition (Only 3 segments shown here) and How do you get the ELSEIF to work ?
SCARAMOUCHEII
So the following code
[code]
battery var byte
index0 var byte
adin 19, battery
’
’ start up LED sequence to let the user know the unit powered up
’
high 15
pause 50
high 14
pause 50
low 15
pause 50
high 13
pause 50
low 14
pause 50
high 12
pause 50
low 13
’
’ leave LED 12 on as the POWER indicator LED
’
start
'
'now lets set the 3 LED array to reflect the state of the battery
'
lookdown battery, < , [20, 80, 180, 200], index0
if index0 = 0 then
low 15
low 14
low 13
'endif
'if index0 = 1 then
elseif index0 = 1 then
high 15
low 14
low 13
'endif
'if index0 = 2 then
elseif index0 = 2 then
high 15
high 14
low 13
'endif
'if index0 = 3 then
elseif index0 = 2 then
high 15
high 14
high 13
endif
as you know “if” should be returned with “endif” after each exception,
the problem you are having is that you have missed these out.
so it should look something like this.
im not a programmer but its something iv pick up on so please dont hole me responsible for servo or board activity.
[code]start
’
'now lets set the 3 LED array to reflect the state of the battery
’
lookdown battery, < , [20, 80, 180, 200], index0
if index0 = 0 then
low 15
low 14
low 13
elseif index0 = 1 then
high 15
low 14
low 13
elseif index0 = 2 then
high 15
high 14
low 13
elseif index0 = 2 then
high 15
high 14
high 13
endif
’
'now lets set the 3 LED array to reflect the state of the battery
’
lookdown battery, < , [20, 80, 180, 200], index0
if index0 = 0 then
low 15
low 14
low 13
else
if index0 = 1 then
high 15
low 14
low 13
else
if index0 = 2 then
high 15
high 14
low 13
else
if index0 = 2 then
high 15
high 14
high 13
endif
endif
endif
endif
IF
THEN
ELSEIF
ELSEIF
ELSEIF
ELSEIF
ENDIF
For someone like me that’s good to know. These are the kind of bugs that seem to find their way in my programs as well. I still struggle with nested IFs beyond two loops