Another cool arduino based led project to get ya going. This project is super cool to show off and easy to build.
Skill Level: Newb
Time: 30 min
Parts Required:
- Breadboard
- Arduino
- 8 Leds
- 8 10k resistors
- Jumper wires
- 10k potentiometer
- Arduino
- 8 Leds
- 8 10k resistors
- Jumper wires
- 10k potentiometer
This is an LED Chaser program with Speed Control
// 8 LED's are connected to the 8 Pins of Arduino
// with a series resistor with each LED
// Potentiometer is Connected to Analog Input pin A0
// refer circuit diagram for reference
// You can Change chaser speed by varying the pot
int led1 = 1;
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int led8 = 8;
int count = 1;
void setup()
{
// put your setup code here, to run once:
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop()
{
// i reads the analog pot value connected to A0 pin
// this value changes from 0 - 1023 giving us a delay of
// 0 to 1023 milliseconds
// count variable carries the number of LED pin
// we reset the count to 1 when it becomes more than 8
// because we have only 8 leds connected
int i = (A0);
digitalWrite(count,HIGH); delay(i);
digitalWrite(count,LOW); delay(i);
count++;
if(count > 8)
{
count = 1;
}
}
Thanks guys more to come.....
No comments:
Post a Comment