Controlling a LED using a switch

Posted on Feb 6, 2014

To create the circuit you will need to connect a switch as an input and an LED as an output to the Arduino. This means that you will need a switch, an LED, a 10k © resistor, a 470 © resistor, a blue or yellow jumper wire, and a red jumper wire. The Arduino pin is connected to the circuit between the resistor and the switch. This is because the digital pin is configured

Controlling a LED using a switch
Click here to download the full size of the above Circuit.

such that it needs a small amount of power to change states. This is useful since we don`t want to draw too much power through the Arduino. However, this also means that if the pin is not connected to a known level in the circuit, it could have any value. This is called floating, since the value of the pin is neither high nor low. To solve this problem we use the resistor to connect the pin to ground. We use a resistor and not just a wire so that we can limit how much current is flowing through the connection. Since we want to minimize the power draw we will use a large resistor, in this case 10k ©. When the switch is not pressed the pin is only connected to ground through the resistor. Since the pin will have what ever voltage value is applied to it, the resistor can be considered as a wire when the switch is not pressed. However, once the switch is pressed, the pin is directly connected to 5V and the resistor limits the current flowing to just 0. 5 mA, and thus prevents a short circuit. Now that we have everything connected, we need to tell ROBOTC how to configure the pins before we can program. We need to tell ROBOTC that we are using the Parallax BOE Shield, and that we have the LED connected to pin 5. We also need to tell ROBOTC that pin 2 is a Digital High Impedance (the led switch with the resistor connected to ground) and name it "ledSwitch". We want the Arduino to turn the LED on when the button is pressed and...

Leave Comment

characters left:

New Circuits



Popular Circuits

Power from PC's RS-232 circuit
Noaa Weather Alert Decoder
Combination Voltage And Current Regulator Circuit
8051 Selling Leads
clap sensor construction
vhfuhf tv modulator
1W FM Transmitter Circuit
TNT1541 diy zero-oversampling dac
Monostable circuit diagram of the use of video amplifiers and comparators
Low drift integrator
Radio remote control lighting switch CD4017 RCM1 schematic