Strange programming error. (With code)

pjl83

Member
Hi All.

I'm making a simple buzzer game using a 14m chip. The kind of game where you go along the track with the wand and if you hit the wire then you lose. I have added a contact point at the end of the track so there can be a win sequence too. Just a buzzer and 2 red led's flashing for lose, and a different buzzer and 2 green led's for win. I've ordered some parts so no circuit yet but I'm trying to write the code. I've written the pins at the top of the code.

I've got a main loop looking for the track to be made or the win button. Once the sequence has run its course, the buzzer turns off, the led's stay on until you press a button to reset.

I'm getting an error "Unknown Symbol" on the first if line of the main loop even though it is identical to lines I've written in other code for my 08m circuits. Any idea why is this an error?

Code:
'Buzzer Lose	=13
'Red led1		=12
'Red led2		=11

'Buzzer win		=10
'Green led1		=9
'Green led2		=8

'Track		=7
'Win Button		=6
'Reset		=5

Main:	'the main loop
	if pin7 = 1 then lose
	if pin6 = 1 then win
	goto main
	
lose: 'lose sequence
	pause 250
	high 13
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	pause 250
	low 12 : low 11
	pause 250
	high 12 : high 11
	low 13
	goto startagain
	
startagain:	'awaiting reset
	if pin5 = 1 then goto main
	goto startagain
	
win: 'win sequence
	pause 250
	high 10
	high 9
	high 8
	wait 5
	low 10
	goto startagain

Thanks
Paul
 

MartinM57

Moderator
Looks to me that you are using the physical leg numbers rather than the PICAXE pin numbers - confusing innit :)

See Manual 1 about page 9 for the 14M connections.

So the first line of code should be

Code:
if pin0 = 1 then lose  ' leg 7
etc, throughout your code
 

pjl83

Member
Thankyou.

Its funny how you forget the simplest of things when you've not used it for a while.

I've just changed things and gone through the simulator and all is well.

Thanks again
Paul
 
Last edited:

vttom

Senior Member
Do you think you should add a 3rd contact at the beginning of the track and program it so that the game won't start unless the player is making contact at the beginning? Otherwise, they could just move the wand to the end, hit reset, and instantly win the game.
 

pjl83

Member
Good idea. I hadn't thought of that. I'll see if I can fit one into the box. It might be too late now as I already have it built.

Thanks
 

vttom

Senior Member
Experience has taught me to think about not only how my project will be used, but also how it will be mis-used, and to plan accordingly. :)
 
Top