Code Section:

int sensorPin = A0; // select the input pin for LDR
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600); //sets serial port for communication
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
Serial.println(sensorValue); //prints the values coming from the sensor on the screen
if( sensorValue<300)
  {
    digitalWrite(13,HIGH);
  }
  else digitalWrite(13,LOW);

delay(100);
}

 

SHARE
Previous articleWiFi Controlled Robot
Next articleWall Follower Robot

LEAVE A REPLY

Please enter your comment!
Please enter your name here