December 23, 2018

Arduino Theatre dim lights tutorial


ARDUINO THEATRE DIM 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 theatre dim lights. The dimming or fading of lights is observable in theatres, car interior cabin lights, etc. Dimming or fading is a process of gradually increasing or decreasing the brightness of light. The theatre dim light setup consists of three yellow LED’s. Together they switch on and off gradually within a specified time. The time value here is 300 millisecond.  

COMPONENTS REQUIRED

1. Breadboard
2. Arduino UNO and USB cable
3. Three 5mm Yellow LED’s
4. Three 20 Ohm resistors
5. Jumpers
6. A 5V Power supply

CIRCUIT SCHEMATICS

Figure.1 Arduino theatre dim lights schematic

Make the appropriate connections as shown in the schematic above

CODE

This is the code for simulating Arduino Theatre dim 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 but ensure only analog pins are selected. Analog pins are usually marked with a ‘~’ in front of the pin number. Copy and paste the code in Arduino IDE sketch area.

int led1 = 3;           // the PWM pin the LED is attached to
int led2 = 5;
int led3 = 6;
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
  // declare pins 3,5,6 to be outputs:
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pins 3,5,6:
  analogWrite(led1, brightness);
  analogWrite(led2, brightness);
  analogWrite(led3, brightness);
  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;
  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  // wait for 300 milliseconds to see the dimming effect
  delay(300);
}

No comments:

Post a Comment