Step 4The Code
/*
- Jonathan Robson Feb 09.
- Laser tripwire activates a buzzer. adapted from
- http://www.instructables.com/id/Arduino_Laser_Tripwire/
int buzzPin = 11; // buzzer connected to digital pin 11
void setup() {
pinMode(buzzPin, OUTPUT); // sets the digital pin as output
}
void loop(){
if(analogRead(0) < 850){ // this number depends on calibration of the photocell
digitalWrite(buzzPin, HIGH); // turns buzzer on
delay(1000); // waits for 1 second
digitalWrite(buzzPin, LOW); // turns buzzer off
} else{
digitalWrite(buzzPin, LOW);
}
}
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|





































