I've been struggling with this for a few days, reduced the circuit and program to its lowest common denominator and it still won't work. Can some one suggest what to try?
What it is supposed to do. I wanted to find a simple way to input a value into a variable (low number 0-15). To that end I have a pushbutton switch and led. The thing works as expected: I press down on the button, turn on power, and count the number of times the led flashes - then after a delay it flashes the led the same number of times and shuts off.
Things get hinky when I try to get it to commit the last number of flashes to EEPROM. The "remarked" commands for write and read in the program. If I put the read command alone, it flashes continuously (like some high number is in b0) - without ever pushing the button (after a clean program loaded).
The write command without the read causes the circuit to work normally until the led is supposed to flash back the value of b0 - nothing in b0 and no flashes, but if I do press the button it flashes normally while the button is down then comes on and stays on when the button is released and some of the other output pins go high even though there's nothing programmed into them.
Have I got the read and write commands in the correct place to do what I want and am I using them correctly?
What it is supposed to do. I wanted to find a simple way to input a value into a variable (low number 0-15). To that end I have a pushbutton switch and led. The thing works as expected: I press down on the button, turn on power, and count the number of times the led flashes - then after a delay it flashes the led the same number of times and shuts off.
Things get hinky when I try to get it to commit the last number of flashes to EEPROM. The "remarked" commands for write and read in the program. If I put the read command alone, it flashes continuously (like some high number is in b0) - without ever pushing the button (after a clean program loaded).
The write command without the read causes the circuit to work normally until the led is supposed to flash back the value of b0 - nothing in b0 and no flashes, but if I do press the button it flashes normally while the button is down then comes on and stays on when the button is released and some of the other output pins go high even though there's nothing programmed into them.
Have I got the read and write commands in the correct place to do what I want and am I using them correctly?
Code:
pause 100
'read 201 ,b0 'read the count XXXXXXXXXXX
pause 100
MAIN:
IF PIN3 = 1 THEN MAIN2
LOW 4 'turns on led
PAUSE 10
b0 = b0 + 1 'increments b0 count
pause 300
HIGH 4 'turns off led
PAUSE 300
IF PIN3 = 0 THEN MAIN 'if the button is still pressed it
'continues to flash and increment
PAUSE 300
'write 201, b0 'write count into mem location 201 XXXXXXXXX
PAUSE 300
IF PIN3 = 1 THEN MAIN2 'if the button is released it plays
'back the same # of flashes as b0
MAIN2:
if b0=0 then stops
for b5 = 1 to b0 'beginning for/next loop, flash N times
pause 500 'three seconds between flashes
low 4 'pin 3 high, turn on LED
pause 500 'turn on for 10 milliseconds
high 4 'pin 3 low,turn off LED
next b5 'back to for/next loop
pause 200
stops:
end