Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Roshanteja21 authored Oct 6, 2021
1 parent b527d05 commit 3fc965a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Counter using IR sensor/COUNTER_WITH_IR.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#define buzzer 5 // buzzer at pin 5
#define sensor 6 // ir sensor at pin 6
int sound=250; // set buzzer sound
void setup()
{
Serial.begin(9600);
pinMode(sensor,INPUT);
pinMode(buzzer,OUTPUT);
}

void loop()
{
int detect=digitalRead(sensor); // read status of sensor
if(detect==HIGH) // if sensor detects obstacle
{
tone(buzzer,sound); // buzzer sounds
}
else{
digitalWrite(led,LOW);
noTone(buzzer);
}
delay(300);
}

0 comments on commit 3fc965a

Please sign in to comment.