How on earth do you do it ???????????

TEZARM

Senior Member
Someone please help me. Heres an example.

Picaxe 18a. Ok Pin 1 is the TURN ON trigger (A N/O Switch going to ground when closed).
Pin 2 is the TURN OFF trigger (Also a different N/O Switch going to ground when closed).
Pin 3 is my output with my led which is a loop so it flashes.
OK. So when pin 1 is pushed once it grounds the pin turning led on, (Flashing, lets say every second).
Now comes the PROBLEM. When I push pin 2 once it SHOULD goto ground till i let go of switch AND STOP THE LED FROM FLASHING. But it doesn't very reliably do this. It seems as if you have time it right just before the led starts to turn on again from it's last flash. It's so frustrating. Why does it do that????
No point posting my code on hear as it's ridiculous and will confuse you even more as I have no idea what on earth I am doing. Please help, I am terrible at the Programming side of Picaxes.
 

ylp88

Senior Member
Make sure you have a pullup resistor on each of your PICAXE input pins, say 4.7k to 10k each. It sounds like you may have some floating inputs.

ylp88
 

TEZARM

Senior Member
hi yip88. No I have that part right, the problem seems to be the flash rate of led. Because if I leave a say 2 second gap between the time the led turns off after a flash till the next time it turns on again I can get it to turn off NO Problems whatsoever. But a flash rate of say 500ms creates problems. It's almost as if there is a command I need to use to interrupt the flashing of led. Am I making nay sense?
 

BeanieBots

Moderator
Unless you are using interrupts to catch the switch pushes, you will need to test the inputs more frequently. Break the pauses down into small intervals and test after each step. This is best achieved by putting a small delay inside a for/next loop.
 

Rickharris

Senior Member
It will help us if you post your code.

You can not turn the LED off until your programme has checket the status of the input.

try this untested code
Start:
if pin1=0 the flash
goto start

flash:
high 3
if pin2=0 then start
wait 1

low 3
if pin2=0 then start
wait 1

if pin2=0 then start
goto flash


This will check the input during the flashing loop as well.
 

TEZARM

Senior Member
Ahhh. BeanieBots and Rick. That sounds like the answer to my problem. I will test out Ricks Code and get back to ya. Thanks Guys.
 

evanh

Senior Member
As BeanieBots hinted, using interrupts to terminate the pause is even faster and more accurate.


Evan
 

TEZARM

Senior Member
evanh. Yes I am guessing BeanieBots Interrupts idea is the best but Me and Interrupts don't get along. I don't get them at all and when trying to program them into a whole page of Code is a Nightmare for me.
 
Top