Let's Catch the Thief

TLIOB004

Jugaadu's father is a shopkeeper; one of his servants steals money while he is busy with other work. Can Jugaadu make something to catch a thief who tries to do the same?
Digital Kit
  1. Place the IR sensor close to the box backside.
  2. Connect IR module with Arduino, Switch, battery and buzzer using connecting wires.
  3. Program the Arduino and upload the sketch Using A to B USB Cable.
  4. Test the positioning and fix it.

    

int out = 2;
int buz=11;
int bt=7;
void setup() {
// put your setup code here, to run once:
pinMode(out,INPUT);
pinMode(buz,OUTPUT);
digitalWrite(buz,LOW);
Serial.begin(9600);
pinMode(bt,INPUT);
}

void loop() {

// put your main code here, to run repeatedly:
if(digitalRead(bt)==LOW){
if(digitalRead(out)==HIGH)
{digitalWrite(buz,HIGH);
Serial.println(out);
Serial.println("stop something is ahead");
}else{
digitalWrite(buz,LOW);
Serial.println("path is clear");
} }
else{
digitalWrite(buz,LOW);
}
}