Go Down

Topic: 1 pushbutton switches 2 leds (Read 408 times) previous topic - next topic

zeisig

Aug 24, 2020, 02:13 am Last Edit: Aug 25, 2020, 05:47 am by Coding Badly
hello, i am working on a project that includes 1 pushbutton and two leds.
when the button is pushed the red led will come on 2 times for 1 sec. each.
when the button is released the green led will come on 2 times for 1 sec. each.
i have seache high and low for a sketch and did not find anything that came close.
i am new to arduino programing, so please excuse my lack of knowledge.
if anybody could help me out on this one i would realy appreciate it.
thank for your time.

larryd

" i have seache high and low for a sketch and did not find anything that came close."

That's not how it works.

The answer is in your head.

'You' put the effort into learning coding and interconnecting electronic components and out pops out the answer.




No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

dougp

Start by reading the Arduino Reference Page.  Many details are explained and examples given.

Also - How to use this forum.
I don't trust atoms.  They make up everything.

No private consultations undertaken!

Paul__B

And you have failed to specify the actual requirement.

You say "the red led will come on 2 times for 1 sec. each".  Well, that may mean something in your head, but it does not actually explain anything.  Does it mean the LED will come on for one second and come on for another second a year later?

Now you may think this is trivial, but it is simply muddled thinking.  The computer - the microprocessor - operates by absolutely strict logic; you must tell it everything and that includes how long the LED must wait between blinks.

Do you know how to wire the button?  You connect it between a pin and ground, and you set pinMode for that pin to INPUT_PULLUP.

Do you know how to wire the LEDs?  You need a series resistor.  Do you know what value is appropriate?

What have you done so far?  Do you understand all that I have said?  If not, you have a lot of study to do before you start on the project you describe.  :smiley-roll:

The code would be dead easy to hack (poorly), but I doubt anyone is eager just to give even that to you unless you demonstrate somewhat more effort!  :smiley-eek:



Paul__B

Ah yes, I missed that - I usually do mention it each time this same question has been asked - but I think I gave enough things to start with in any case.  :smiley-lol:

zeisig

thank you for your quick replay, i will study some more. thanks again.

Paul__B

Altering the subject heading of your first post to adapt to reponses is OK.

Removing the content is not at all respectful.  :smiley-eek:

(deleted)

#9
Aug 24, 2020, 03:25 pm Last Edit: Aug 24, 2020, 03:25 pm by tove_pedersen
(deleted)

Coding Badly


@zeisig, do not vandalize the forum again.


Paul__B

Ah!  You recovered it!  Well done!

Go Up