Tuesday, February 7, 2012
Monday, February 6, 2012
Electrical Circuits and LEDs
Both these circuits turn on an LED when a button is pressed.
One circuit is simple. It uses no microcontroller. When the momentary push-button is
pressed, the circuit is completed, and the LED turns on. We use a 220 Ohm resistor
with the LED because otherwise, the LED would burn out.
The second circuit uses a programmable microcontroller.
The LED that is turned on/off is permanently connected through a resistor to the
microcontroller board at pin 13.
The momentary push-button is connected to digital pin 2 and 5v.
Digital pin 2 is also connected to GND via a 10k resistor.
If the resistor were not there, the LED might flicker as a result of the pin “floating”.
“Floating” means that the pin is neither connected to GND nor to 5v when the button
is not pressed. A “floating” pin may lead to a flickering LED.
Therefore, pin 2 has to be connected to GND through a resistor. This will cause the
pin to sense GND when the button is not pressed, and 5v, when it is pressed.
The program uploaded to the microcontroller creates the connection between the
state of the button (on/off) and the state of the LED (on when button is pressed, off
when it is not pressed).
Subscribe to:
Posts (Atom)