Begineer Problem
akla
Posts: 2
Hi ! iam begineer in microcontroller. iam using BS2sx for controlling my final year project.
i want my output5 high when input1 on and off for·5 times. please someone check my program. its not working.counter is not·accurate.
INPUT 1
OUTPUT 5
cnt VAR Byte
cnt = 0
MAIN :
····· IF IN1=1 THEN ADD
····· GOTO MAIN
ADD:
····· PAUSE 1000
····· cnt = cnt +·5
····· IF cnt <·5 THEN MAIN
····· HIGH 5
····· DEBUG " OK "
····· GOTO MAIN
regards
aklaken.
i want my output5 high when input1 on and off for·5 times. please someone check my program. its not working.counter is not·accurate.
INPUT 1
OUTPUT 5
cnt VAR Byte
cnt = 0
MAIN :
····· IF IN1=1 THEN ADD
····· GOTO MAIN
ADD:
····· PAUSE 1000
····· cnt = cnt +·5
····· IF cnt <·5 THEN MAIN
····· HIGH 5
····· DEBUG " OK "
····· GOTO MAIN
regards
aklaken.
Comments
I'm a bit surprised it's not more intuitive that if you want to increment a counter by one, you add one to it, not 2, 5 or anything else:
cnt = cnt + 1 'Increment the counter by one
Regards,
Bruce Bates
thanks again
regards
aklaken·
Dave
You say in your program than you want to "press and release" the button; the code below shows how (one method, there are many) to do that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA