ARDUINO
STREET LIGHTS PT2 TUTORIAL
INTRODUCTION
Arduino is a
microcontroller which can be programmed to do certain operations like lighting
led, controlling servo, etc. This is a DIY Arduino project intended to simulate
street lights using 20 LED’s and transistors for amplification. Currently due
to advancements in technology, LED’s are replacing incandescent, fluorescent
and halogen lamps. LED’s are inexpensive, robust and most importantly
efficient. LED’s are already powering many parks, streets in cities and
villages. They themselves are recharged by solar power thus they represent a
completely green source of energy.
COMPONENTS
REQUIRED
1. Breadboard
2. Arduino
MEGA and USB cable
3. 5mm
White LED’s (20 nos.)
4. 20
Ohm resistors (20 nos.)
5. 10
Ohm resistors (20 nos.)
6. NPN
Transistor (20 nos.)
7. Jumpers
8. A 5V
DC Power supply
CIRCUIT SCHEMATICS
Fig.1 Arduino street light pt2 schematic |
Make
the appropriate connections as shown in the schematic above
CODE
This
is the code for simulating Arduino Street lights version 2. Note that this code
is valid only for the particular schematic represented in figure1. The values
and choice of ports can always be changed. The schematic only displays for 5
LED’s due to lack of space. Mimic the same setup for other LED’s as well. The
given code is for 20 LED’s. Copy and paste the code in Arduino IDE sketch area.
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
pinMode(16, OUTPUT);
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
pinMode(20, OUTPUT);
pinMode(21, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);
digitalWrite (7, HIGH);
digitalWrite (8, HIGH);
digitalWrite (9, HIGH);
digitalWrite (10, HIGH);
digitalWrite (11, HIGH);
digitalWrite (12, HIGH);
digitalWrite (13, HIGH);
digitalWrite (14, HIGH);
digitalWrite (15, HIGH);
digitalWrite (16, HIGH);
digitalWrite (17, HIGH);
digitalWrite (18, HIGH);
digitalWrite (19, HIGH);
digitalWrite (20, HIGH);
digitalWrite (21, HIGH);
}
No comments:
Post a Comment