Servomotor control using LDR


Microservo motor control using LDR 

Hello friends in this blog you are learn How to control a micro servomotor using LDR



Components required 

1. Arduino uno

2. Micro servomotor 

3. LDR (Light dependent resistor)

4. 1k Ohm resistor 

5. Few Male to male jumper wires


Circuit diagram 





Program code 

//@BigEdx youtube channel
#include<Servo.h>
Servo servomotor;
void setup() {
  servomotor.attach(3); //servomotor connect to arduino ~ PWM pin 3
}

void loop() {
  // Analog input from LDR to A1 pin:
  int value= analogRead(A1);
  if(value<300){
    servomotor.write(180);
  }
    //servmotor rotate 180
  else{
    servomotor.write(0);
  } 
    //servmotor rotate 0
}


Program view 


Program explanation 

Micro servomotor signal wire connected to Arduino PWM pin ~3 

and LDR analog input wire connected to Arduino A1 pin 

When Light intensity  focus increases on ldr then servomotor rotate 180 degree and light intensity not focusing on LDR then servomotor rotate 0 at their home position

 If you facing any problem you are free to contact me 

Email 

Rajeevkashyap760@gmail.com





Post a Comment (0)
Previous Post Next Post