Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Sriram MN
Published © GPL3+

Simple Movement Detector

This project is about a simple movement detector. Whenever any obstacle comes in a line (predefined) a light will glow.

IntermediateShowcase (no instructions)3 hours6,246
Simple Movement Detector

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
LDR
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit Diagram

Code

Code for the system

Arduino
int sensorPin = A0; // select the input pin for LDR

int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600); //sets serial port for communication
pinMode(2,OUTPUT);
pinMode(12,OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
digitalWrite(2,1);
Serial.println(sensorValue); //prints the values coming from the sensor on the screen

delay(1);
if(sensorValue<80)
{
  digitalWrite(12,1);
}
else 
{
  digitalWrite(12,0);
}
}

Credits

Sriram MN
5 projects • 8 followers
A Engineering student who just stepped into the world of electronics. Interested in Astronomy,Robotics,Iot,Quantum phenomenon,Ml and AI .

Comments