Components Required –
Circuit Connections –
Fig. 2: Prototype of Automatic and Manual Control of Stadium Lights
How the circuit works –
Fig. 3: Image of Automatic and Manual Control of Stadium Lights in action
Once the Arduino board is powered on, the board initializes the circuit and set the pins digital output or input. It checks the status of pins connected to the SPDT switches. If the switch connected at pin 9 has HIGH while switch connected at pin 8 has LOW, the automatic mode is selected and the LED lights are operated according to the LDR sensor. If the switch connected at pin 9 has LOW while switch connected at pin 8 has HIGH, the manual mode is selected and LED lights are operated according to the potentiometer. If both the switches have LOW, the LEDs are switched OFF by sending a LOW logic at the pin 6 of the board.
Programming Guide –
Project Source Code
###
//Program to int potPin= A1; int LDR = A0; int LED= 6; int sw1 = 9; int sw2 = 8;void setup() { pinMode(potPin, INPUT); pinMode(LDR, INPUT); pinMode(LED, OUTPUT); pinMode(sw1, INPUT); pinMode(sw2, INPUT); }
void loop() { int SWITCH1 = digitalRead(sw1); int SWITCH2 = digitalRead(sw2); if (SWITCH1 == HIGH && SWITCH2 == LOW) { ldr(); } else if (SWITCH2 == HIGH && SWITCH1 == LOW) { pot(); } else if (SWITCH2 == LOW && SWITCH1 == LOW) { digitalWrite(LED,LOW); } }
void pot() { int readValue = analogRead(potPin); int writeValue = (255./1023.) * readValue; analogWrite(LED, writeValue); }
void ldr() { int sv = analogRead(LDR); int wv = (255./1023.) * sv; analogWrite(LED, wv); }
###
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.