output serial monitor, goes on and on and on
hi,
i'm new forum, , after reading lots of different tutorials , try find solution problem myself i'd hope somebody
can me.
hi have push button , led light, want serial monitor following. report on/off 1 time per change.
so lets led off, there should in serial monitor 1 time off, until next change taking place.
zo somiting like
off
on
off
on
off
on
i tried delay , other possibilities no success
the next project want make pushbutton led, led show how many times button has been pressed, 1 time blink once en delay 5 sec. , if pressed blink 2 times , delay 5 sec. hope can magage myself
i'm new forum, , after reading lots of different tutorials , try find solution problem myself i'd hope somebody
can me.
hi have push button , led light, want serial monitor following. report on/off 1 time per change.
so lets led off, there should in serial monitor 1 time off, until next change taking place.
zo somiting like
off
on
off
on
off
on
i tried delay , other possibilities no success

the next project want make pushbutton led, led show how many times button has been pressed, 1 time blink once en delay 5 sec. , if pressed blink 2 times , delay 5 sec. hope can magage myself

it sounds need keep record of last state.
then, each time through "loop()" see if state read button has changed.
if has, print new state, , store new state.
(uncompiled, untested)
then, each time through "loop()" see if state read button has changed.
if has, print new state, , store new state.
(uncompiled, untested)
code: [select]
byte laststate;
...
...
void printstate (byte state)
{
serial.println(state ? "high" : "low");
}
..
..
void setup ()
{
...
laststate = digitalread (buttonpin);
printstate (laststate);
}
void loop ()
{
byte newstate = digitalread (buttonpin);
if (newstate != laststate) {
printstate (newstate);
laststate = newstate;
}
}
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > output serial monitor, goes on and on and on
arduino
Comments
Post a Comment