const int LDR = 2; //LDR is connected to pin 2
const int red = 14;
const int green = 12;
int threshold =1000;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LDR,INPUT); //Configure pin 2 as an input
pinMode(red,OUTPUT); // RED LED SET AS OUTPUT
pinMode(green,OUTPUT);//Green LED set as OUTPUT
delay(2000);
Serial.println("Hello User");
delay(2000);
Serial.println("Initailizing.");
delay(2000);
Serial.println("Initailizing..");
delay(2000);
Serial.println("Initailizing...");
delay(2000);
Serial.print("Threshold value is : ");
Serial.println(threshold);
}
void loop() {
analogRead(LDR); //Read values from analog pin 2
float LDRVALUE = analogRead(LDR); //Creates a variable that reads the values
Serial.print("The LDR value is:");
Serial.println(LDRVALUE);
delay(2000);
if (threshold>LDRVALUE) {
digitalWrite(green, LOW);
digitalWrite(red, HIGH);
Serial.println("Light intensity is bellow threshold");
}
else if (threshold <LDRVALUE ) {
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
Serial.println("Light intensity is above threshold");
}
}
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
ldr1:VCC
ldr1:GND
ldr1:DO
ldr1:AO
led1:A
led1:C