December 2, 2018

Arduino Club lights tutorial


ARDUINO CLUB LIGHTS 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 club lights. Clubs usually have cool colors like red, pink, blue and purple. These colors are flashed randomly without any pattern which creates a perfect environment for disco and partying.

COMPONENTS REQUIRED

1. Breadboard
2. Arduino UNO and USB cable
3. 5mm Red LED (5 nos.)
4. 5mm Blue LED (5 nos.)
5. 20 Ohm resistors (10 nos.)
6. Jumpers
7. A 5V DC Power supply

CIRCUIT SCHEMATICS

Figure.1 Club lights schematic

Make the appropriate connections as shown in the schematic above

CODE

This is the code for simulating Arduino Club lights. Note that this code is valid only for the particular schematic represented in figure1. The values and choice of ports can always be changed. Copy and paste the code in Arduino IDE sketch area.

void setup() {

  pinMode(2, OUTPUT);  //red led
  pinMode(3, OUTPUT);  //blue led
  pinMode(4, OUTPUT);  //red led
  pinMode(5, OUTPUT);  //blue led
  pinMode(6, OUTPUT);  //red led
  pinMode(7, OUTPUT);  //blue led
  pinMode(8, OUTPUT);  //red led
  pinMode(9, OUTPUT);  //blue led
  pinMode(10, OUTPUT);  //red led
  pinMode(11, OUTPUT);  //blue led
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the red led on
  delay(100);              // wait for some time
  digitalWrite(2, LOW);    // turn the red led off
  delay(100);              // wait for some time
  digitalWrite(3, HIGH);   // turn the blue led on
  delay(100);             // wait for some time
  digitalWrite(3, LOW);    // turn the blue led off
  delay(100);              // wait for some time
  digitalWrite(4, HIGH);   // turn the red led on
  delay(100);             // wait for some time
  digitalWrite(4, LOW);    // turn the red led off
  delay(100);              // wait for some time
  digitalWrite(5, HIGH);   // turn the blue led on
  delay(100);             // wait for some time
  digitalWrite(5, LOW);    // turn the blue led off
  delay(100);              // wait for some time
  digitalWrite(6, HIGH);   // turn the red led on
  delay(100);             // wait for some time
  digitalWrite(6, LOW);    // turn the red led off
  delay(100);              // wait for some time
  digitalWrite(7, HIGH);   // turn the blue led on
  delay(100);             // wait for some time
  digitalWrite(7, LOW);    // turn the blue led off
  delay(100);              // wait for some time
  digitalWrite(8, HIGH);   // turn the red led on
  delay(100);             // wait for some time
  digitalWrite(8, LOW);    // turn the red led off
  delay(100);              // wait for some time
  digitalWrite(9, HIGH);   // turn the blue led on
  delay(100);             // wait for some time
  digitalWrite(9, LOW);    // turn the blue led off
  delay(100);              // wait for some time
  digitalWrite(10, HIGH);   // turn the red led on
  delay(100);             // wait for some time
  digitalWrite(10, LOW);    // turn the red led off
  delay(100);              // wait for some time
  digitalWrite(11, HIGH);   // turn the blue led on
  delay(100);             // wait for some time
  digitalWrite(11, LOW);    // turn the blue led off
  delay(100);              // wait for some time

}

No comments:

Post a Comment