r/ArduinoHelp • • 2d ago

Arduino circuit connection

Post image

Anyone well versed in arduino . Please help me to built a little circuit for when i touch the push button ,the led turns on for 2 sec then off

1 Upvotes

4 comments sorted by

1

u/gm310509 2d ago

You might start by looking at the builtin examples: https://docs.arduino.cc/built-in-examples/

Start with blinking the LED.

Then do a button example.

These are all well documented already - having a custom written guide just for you won't beat what is already out there.

After you get those two working seperately, try making it so that the button turns the LED on/off. After that use the code in the blink program to make it so that it when turned on it reamins on for 2 seconds and then automatically turns off (i.e. without the second button press).

Have a go yourself and if you get stuck but don't please don't ask others to do your project for you - you need to at least try.

1

u/beast_boy_08 2d ago

Thank you bro . I will learn from this document then i continue my project

3

u/yeehah 2d ago

C'mon, you're not even trying. If you just Google "Arduino circuit for when i touch the push button ,the led turns on for 2 sec then off," you'll get dozens of helpful links. In AI mode, you'll get the circuit and the code too. Being good at computers requires knowing how to look things up on the Internet.

1

u/gm310509 2d ago

LOL, only dozens? My Google must be better than yours as I got 152,000 (estimated) results! :-)

I also got two different AI slop solutions (one from google and one from duckduckgo) - both of which left nowhere to go as they both used inline blocking techniques in the generated code.

Interestingly both "randomly" happened to choose pin 2 for the button and pin 8 for the LED.

The differences were:

  • One AI said use a 220 Ω resistor, the other gave a range 200-330Ω but more interestingly:
  • The other difference was in what was done if the button was held down for 2 seconds or more (i.e the bit not specified in your "spec"):

    • The first used blocking code to wait for the button to be released (after turning off the LED.
    • The second turned off the LED after two seconds but immediately returned from the loop - which would immediately detect the button was still pressed and initiate another 2 seconds.

So despite the somewhat odd (to me at least) exact same GPIO pin usages, they had quite different approaches to the unspecified aspect of holding the button down.