Arduino with an external Switch

This is part of the starter blog for Arduino basics. Check out here to see all of them.

In many situations we need an external switch to control something in the circuit. Say you make an RC car, of course you will need to control it via a remote! which will have buttons on it. So today we are gonna light an LED with a switch as a basic. Once you go through it you can extend the same concept to any control any component say motor, relay and so on. Lets get started!

~What you need~

You are going to need the following parts for building the circuit. Of course your PC is needed as well.

  1. Arduino UNO
  2. Switch (may be toggle or button)
  3. LED
  4. 10k resistor
  5. Breadboard
  6. Connecting wires.

Following is an image of all the parts.

~What to do~

Now lets get to the circuit. Below is the circuit diagram of the project. Its pretty much self explanatory, but I’ll still guide you through the steps. Keep reading.

  1. First connect one end of the 10k resistor to gnd(ground) pin and the other end to pin 6.
  2. Now connect the switch between 5V pin and pin 6.
  3. Take an LED and connect its -ve terminal to gnd pin.
  4. Connect the other terminal to pin 12 via the 1k resistor.

Type the following code in the IDE and upload it.

That’s it you are done! Now toggle the switch and see the LED switch on and off :-)! Enjoy!!

Now you must be thinking what now. Of course you can improve on the above circuit and add some stuff, but why not move on? to some other project? Check out the following links if you wish.


Arduino with an external switch
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: