Siman Says help

#1
I am just learning about PICs and I have bought the simon says kit. However the program given on the software samples (which is the same as given in the data sheet) does not work. It keeps saying ERROR: Loop without do (in section 4 of the program)
Ahhhhh what do I do?

Please help.
 
#2
This should work :)
Code:
‘ Simon Says Game
‘ For PICAXE-28
‘ Start switch on input 0
‘ Push swithes on inputs 1-4
‘ LEDs on outputs 1-4
‘ Piezo on output 5
symbol rand = b1 ‘ random for loading memory
symbol key = b2 ‘ switch 1-2-3-4
symbol position = b3 ‘ position of player in game
symbol freq = b4 ‘ sound variable
symbol counter = b5 ‘ number of steps in sequence
‘ *** This section waits for start ***
‘ wait for start switch to be pushed
‘ with all four LEDs lit
‘ preload rand with any number by repeatedly
‘ using the random command in the loop
init:
let pins = %00001111
random rand
if pin0 = 1 then preload
goto init
‘ *** This section loads memory for game ***
‘ load EEPROM memory with 64 numbers
‘ first get the random number (0 to 255)
‘ and then change to either 1,2,3 or 4
‘ and then save into data memory
preload:
for position = 0 to 63
let key = 0
random rand
if rand > 180 then set1
if rand > 120 then set2
if rand > 60 then set3
set4: let key = key + 1
set3: let key = key + 1
set2: let key = key + 1
set1: let key = key + 1
write position,key
next position
‘ *** This section plays back a sequence ***
‘ switch off the LEDs and then start
‘ a game with the end counter as 1
let pins = %00000000
let counter = 1




‘ playback the game sequence
playback:
for position = 0 to counter
read position,key
gosub beep
pause 500
next position
‘ *** This section detects the players reply sequence ***
‘ now the user responds
‘ reset the players position to 0
position = 0
‘ get the correct key player is supposed to hit
‘ from the EEPROM memory
gameloop:
read position,key
‘ if position is equal to counter then all done
if position = counter then success
‘ else wait for switch to be pressed
loop1:if pin1 = 1 then played1
if pin2 = 1 then played2
if pin3 = 1 then played3
if pin4 = 1 then played4
if pin0 = 1 then preload
goto loop1
‘ switch pressed so check it is the correct one
‘ if it is make a beep sound and then continue
‘ else fail the game
played1:
if key <> 1 then fail
let position = position + 1
gosub beep
goto gameloop
played2:
if key <> 2 then fail
let position = position + 1
gosub beep
goto gameloop
played3:
if key <> 3 then fail
let position = position + 1
gosub beep
goto gameloop
played4:
if key <> 4 then fail
let position = position + 1
gosub beep
goto gameloop
&#8216; *** Failed so make noise and jump back to start ***





&#8216; failed so make failed noise, light all LEDs
&#8216; and go back to start
fail:
pause 250
let pins = %00011110
sound 5,(100,300)
goto init
&#8216; *** Succeeded so add another step to sequence and loop ***
&#8216; success so make a success sound
&#8216; and then increment counter and do another sequence
success:
pause 50
sound 5,(50,100)
pause 50
sound 5,(50,100)
pause 500
let counter = counter + 1
goto playback
&#8216; *** sub light LED and beep ***
&#8216;sub-procedure to light correct LED
&#8216;and make a different beep sound for each LED
&#8216;key always contains number 1,2,3 or 4
&#8216;multiply sound freq by 10 to give larger difference
beep:
high key
freq = key * 10
sound 5,(freq,100)
low key
return
 
Last edited:
#3
It's because this code was made before the advanced editor option and the word "LOOP" wasn't a keyword.

In the PICAXE editor, go to VIEW> OPTIONS> click the EDITOR tap. There you can choose the "ORIGINAL" or the "ENHANCED" compiler.
 
#4
You have posted in the Finished Project setion
of the Forum, try posting into the Main Forum.

Try changing the Program Editor config-
e.g. Top Tool Bar - View / Options / select the Editor Tag -
Compiler has either Original or Enhanced mode.

I couldn't locate simon.bas or whatever the file is to try it out.
 
Top