Pushbutton (on/off)
Archiver
Posts: 46,084
I know this has to be simple, but I just can't seem to get it.
I am using a BS2SX and a NX 1000 Experiment Board.
I want to turn an LED on with one push of a button, then turn it off again
with a push of the same button...........Reliably. The time it is pushed
allows a debounce routine (working fine).
Help please!
Lee
--
Registered Linux user #223705
Give me ambiguity or give me something else.
I am using a BS2SX and a NX 1000 Experiment Board.
I want to turn an LED on with one push of a button, then turn it off again
with a push of the same button...........Reliably. The time it is pushed
allows a debounce routine (working fine).
Help please!
Lee
--
Registered Linux user #223705
Give me ambiguity or give me something else.
Comments
operator to make this easy. Let's say your LED is on pin 0:
MyLED VAR Out0
Init:
OUTPUT 0
The code above names your pin and sets its direction to output. After you
debounce the switch, you can invert the state of the LED like this:
MyLED = ~MyLED
It's that simple.
-- Jon Williams
-- Parallax
In a message dated 7/4/02 9:51:24 AM Central Daylight Time,
dlwiggers@a... writes:
> I know this has to be simple, but I just can't seem to get it.
>
> I am using a BS2SX and a NX 1000 Experiment Board.
>
> I want to turn an LED on with one push of a button, then turn it off again
> with a push of the same button...........Reliably. The time it is pushed
> allows a debounce routine (working fine).
>
> Help please!
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
one step further.
I don't want to change states if I hold the button on. Then regardles of the
time element, I release the button, then push it again and it turns the LED
off.
I have programmed PLC's for years, so I have some learning and unlearning to
do.
I appreciate your help.
Lee
> You can use the Stamp's ability to alias variables and the bit invert
> operator to make this easy. Let's say your LED is on pin 0:
>
> MyLED VAR Out0
>
> Init:
> OUTPUT 0
>
> The code above names your pin and sets its direction to output. After you
> debounce the switch, you can invert the state of the LED like this:
>
> MyLED = ~MyLED
>
> It's that simple.
>
> -- Jon Williams
> -- Parallax
>
>
> In a message dated 7/4/02 9:51:24 AM Central Daylight Time,
>
> dlwiggers@a... writes:
> > I know this has to be simple, but I just can't seem to get it.
> >
> > I am using a BS2SX and a NX 1000 Experiment Board.
> >
> > I want to turn an LED on with one push of a button, then turn it off
> > again with a push of the same button...........Reliably. The time it is
> > pushed allows a debounce routine (working fine).
> >
> > Help please!
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
> Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
--
Registered Linux user #223705
Give me ambiguity or give me something else.