Dithira Hettiarachchi
Published

LDR servo controller

Move the servo's direction with a single tap on the LDR sensor.

BeginnerFull instructions provided12 minutes2,119
LDR servo controller

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
Board doesn't matter!
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LDR module
×1
Perma-Proto Breadboard Half Size
Perma-Proto Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit diagram

Code

Code

Arduino
#include<Servo.h>

Servo Dithira;//dithira is the tag i selected and it can be changed!!!
void setup() {
  Dithira.attach(9);//the servo motor
pinMode(12,INPUT);//the ldr sensor
}

void loop() {
 if (digitalRead(12)==HIGH){//reading the LDR sensor(looking for shadows)
Dithira.write(60);
delay(100);
} 
else{
 Dithira.write(0);
 delay(100);
}
  


}

Credits

Dithira Hettiarachchi

Dithira Hettiarachchi

7 projects • 5 followers
Python Cooking Web3

Comments