bichon5962
Published © GPL3+

LED project (With motion detector)

This project is developed to learn how to use LEDs on arduino with a motion detector.

IntermediateFull instructions provided721
LED project (With motion detector)

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
LED (generic)
LED (generic)
×2
LED(RGB)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×3
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

DIAGRAM

Code

CODE

C/C++
#define IR_output 7
void setup() {
 pinMode(IR_output,INPUT);
 pinMode(9, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(11, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(2, OUTPUT);
Serial.begin(9600);
}

void loop() {
  if(digitalRead(IR_output)==HIGH){
    Serial.println("detected");
   digitalWrite(10, LOW);
   digitalWrite(5, LOW);
   digitalWrite(9, HIGH);
   digitalWrite(2, HIGH);
  delay(200);
   
  }
  if(digitalRead(IR_output)==LOW){
    Serial.println("no detected");
   digitalWrite(10, HIGH);
   digitalWrite(5, HIGH);
   digitalWrite(9, LOW);
   digitalWrite(2, LOW);
   delay(200);
  }

}

Credits

bichon5962
0 projects • 0 followers

Comments