Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Laser Diode, 655 nm
LDR, 5 Mohm
5 mm LED: Red
Software & Tools
Arduino IDE
Project description
Code
Untitled file
c_cpp
Upload once wired
1const int threshold = 920; 2const int Laser = 9; 3const int Led/Buzzer = 12; 4bool Alarm = false; 5 6void setup() { 7 // put your setup code here, to run once: 8 Serial.begin(9600); 9 pinMode(Laser, OUTPUT); 10 digitalWrite(Laser, HIGH); 11} 12 13void loop() { 14 // put your main code here, to run repeatedly: 15 int Value = analogRead(A0); 16 Serial.println(Value); 17 if(Value < 800){ 18 tone(12, 4000); 19 }else if(Value > 800){ 20 noTone(12); 21 } 22 23 24}
Comments
Only logged in users can leave comments