Devices & Components
Arduino Uno Rev3
Software & Tools
Arduino Web Editor
Arduino IDE
Project description
Code
automatic street light controller
arduino
1#include <SoftwareSerial.h> 2 3int sensorPin = A0; // select the input pin for the LDR 4 5int sensorValue = 0; // variable to store the value coming from the sensor 6 7int led = 3; 8 9void setup() { // declare the ledPin as an OUTPUT: 10 11pinMode(led, OUTPUT); 12 13Serial.begin(9600); } 14 15void loop() 16 17{ 18 19Serial.println("Welcome to TechPonder LDR Tutorial"); 20 21sensorValue = analogRead(sensorPin); 22 23Serial.println(sensorValue); 24 25if (sensorValue < 100) 26 27{ 28 29Serial.println("LED light on"); 30 31digitalWrite(led,HIGH); 32 33delay(1000); 34 35} 36 37digitalWrite(led,LOW); 38 39delay(sensorValue); 40 41}
automatic street light controller
arduino
1#include <SoftwareSerial.h> 2 3int sensorPin = A0; // select the input pin for the LDR 4 5int sensorValue = 0; // variable to store the value coming from the sensor 6 7int led = 3; 8 9void setup() { // declare the ledPin as an OUTPUT: 10 11pinMode(led, OUTPUT); 12 13Serial.begin(9600); } 14 15void loop() 16 17{ 18 19Serial.println("Welcome to TechPonder LDR Tutorial"); 20 21sensorValue = analogRead(sensorPin); 22 23Serial.println(sensorValue); 24 25if (sensorValue < 100) 26 27{ 28 29Serial.println("LED light on"); 30 31digitalWrite(led,HIGH); 32 33delay(1000); 34 35} 36 37digitalWrite(led,LOW); 38 39delay(sensorValue); 40 41}
Downloadable files
automatic street light controller
automatic street light controller
Documentation
automatic street light controller
automatic street light controller
automatic street light controller
automatic street light controller
Comments
Only logged in users can leave comments