Digial Input Push button function.

Jacobsen

New Member
Can anyone help me complete the following routine?

A single push to a button switches LED ON ( IF pin0 = 1 THEN ) and remains like this untill button is pushed again, making LED go OFF. On same entry.
NB. I tried doing it like this, at +5V in on leg 11 LED ON goes on

Using: PICAXE-28X - 4Mhz

How could a routine like this look in Basic-code?

I've been working with the Basic-codes below, but have not been able to make it work.

<code><pre><font size=2 face='Courier'>
;Interrupts Button Pushed

WaitForPin0High:
SERTXD(&quot;Led OFF&quot;,CR,LF)

IF pin0 = 0 THEN WaitForPin0High
SERTXD(&quot;Led ON&quot;,CR,LF)
High 0
Pause 5000
Goto WaitForPin0High
</font></pre></code>

Best regards
Monie
 

BeanieBots

Moderator
(untested)
Main:
If pin0=1 then ChangeState
Goto main

ChangeState:
pause 10
If pin0=1 then ChangeState
toggle 0
goto main
 

Jacobsen

New Member
To BeanieBots
Many thanks for the quick response.
A you fin Basic-codes.
It's working fin ;-)

Best regards
Monie
 
Top