Maker Pro
Maker Pro

Picaxe Program Variable Help

Jasper.carpenter

Sep 23, 2019
3
Joined
Sep 23, 2019
Messages
3
I am trying to make a variable increase every time a sensor senses something. I also want a button to reset the variable counter. I have been trying for a while but I still don't quite get it. This is the code I have so far.
[mod edit: moved to to code box]
Code:
#no_data
start:
readadc c.0,b1
readadc b.5,b3
debug b0

main:
b2=0

sensor:
IF b1= 1 then b2=b2+1
endif
IF b3= 1 then goto start:
goto sensor:

I keep on getting syntax error at line 11 before position 15 (IF b1= 1 then b2=b2+1) saying 'Error: Expected a label not the variable B2'
I have created a loading circuit and plugged the into the sensor, and I have a display but am not sure how to program that either. It would be much appreciated if someone could help me out.
 
Last edited by a moderator:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
According to the manual, pages 107/108 it looks like the single line structure can be used with goto or gosub only.
Use a multiline structure as shown in the manual or e,g, here.
 

Jasper.carpenter

Sep 23, 2019
3
Joined
Sep 23, 2019
Messages
3
Thanks for that, I got it to work now, is there a way for me to display this on a 7 segment display?
 
Top