1 pushbutton switches 2 leds

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.

“ 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.

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

Also - How to use this forum.

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. :roll_eyes:

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! :astonished:

(deleted)

(deleted)

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. :grinning:

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

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

Removing the content is not at all respectful. :astonished:

(deleted)

@zeisig, do not vandalize the forum again.

Ah! You recovered it! Well done!