Header Ads

Header ADS

Controld servo using LDR

/*
 * The code is writed by MD Niloy Hossain, 7 April, 2020
 * Please subscribe Wi Max Bangla
 */#include<Servo.h>
Servo s;
void setup() {
  s.attach(9);// initialize serial communication at 9600 bits per second:
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int value= analogRead(A0);
  if(value<395){
    s.write(180);
  }
  else{
    s.write(0);
  }     // delay in between reads for stability
}

No comments

Theme images by enot-poloskun. Powered by Blogger.