Logo Design by FlamingText.com
Logo Design by FlamingText.com

Thursday, 17 November 2016

Arduino 8 led chaser with glue sticks

D.I.Y Arduino 8 LED Chaser:



This was a super simple build, which me and my lil guy threw together on a past weekend, it runs off an arduino which is then powered by a 9 volt battery, Eight different coloured leds were used as well as eight glue sticks to add in the cool effects. As well I have added a 10k pot which allows adjustment for the speed of flash.

Code: The sketch is very simple you can either just google it, write it, or just copy and paste you lazy bastard u.




// 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 = 8;
int led6 = 9;
int led7 = 10;
int led8 = 11;
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;
  }
}


No comments:

Post a Comment