Friday, 16 January 2015

Arduino LDR Distance Sensor

Hello world!, today we will mke an interesting project. A DIY LDR distance sensor. So, the sender is LEDs and the receiver is
LDR. We need to use the small resistance that's 47 ohm to make the LEDs brighter. But this is the minimal resistance!, or your LED will broke. Make sure your LDR can't see anything(ambient light or anything kind of light) except your LEDs light. We use arduino as a LDR reader

We Need
  • LDR
  • 2 LEDs
  • 2 47 ohm resistor
  • 1K Resistor
  • PCB
  • Some wires
  • Arduino
Analyzing Circuit
  • Connect the first pin at the + of the battery
  • Connect the second pin at the - of the battery
  • Connect the third pin at the arduino pin ...
Arduino Code

This code function is to read your LDR:

int sensor = 0;  //define a pin for Photo resistor
int LED=13;     //define a pin for LED
int distance;
int sensitivity=200;
int Close=500;
void setup()
    Serial.begin(9600);  //Begin serial communcation
    pinMode( LED, OUTPUT );

void loop()
distance = analogRead(sensor);
if (distance < sensitivity)
digitalWrite(LED, HIGH);}




This is using Circuit Wizard software

Robot Eyes

No comments:

Post a Comment