Hi,
I'm very new to arduino.
This is my first project.
I was trying to follow this guide:
https://create.arduino.cc/projecthub/SurtrTech/laser-tripwire-alarm-arduino-e8922b
however, instead of arduino uno R3, I used a pro mini 328p 5v
I'm using a PL2303HXA usb-to-ttl converter to program the arduino
everything works fine when the board is connected to pc and powered via usb.
But as soon as I connect it to ac power, the buzzer is continuously beeping.
I'm not sure what is going on.
Can anyone please help?
Is it possible to monitor the serial output while connected to AC?
I'm afraid to connect it to my laptop when there is already power going in through RAW port.
Is it ok to connect to laptop when the board is connected to AC?
To clear up confusion, I've used a 5v 700mA dc transformer.
Please help.
Thanks.
/* This code is for a LASER Tripwire Alarm based on a light sensor, LASER module and a push button
* The LASER is constantly sending beams to the sensor, when someone passes the light is not detected
* and the alarm goes off, and will not stop until you press the button
* Refer to www.surtrtech.com for more details
*/
#define Rec 8 //Light sensor input
#define Laser 9 //Laser module
#define Button 13 //Push button input
#define Buzzer 11 //Buzzer
bool detection;
void setup() {
pinMode(Laser, OUTPUT);
pinMode(Buzzer, OUTPUT);
digitalWrite(Laser, HIGH); //Turning on the laser
delay(2000);
}
void loop() {
short Detect = digitalRead(Rec); //Constanly reading the module value
bool Button_state = digitalRead(Button); //And the button value (1-0)
if(Detect == 0) //The Max value is 760, if someone passes it goes below that (every value lower than 700 can do the work)
detection = true; //The detection is triggered
if(detection==true)
{
digitalWrite(Buzzer, HIGH); //Turning on the Buzzer
delay(150);
digitalWrite(Buzzer, LOW);
delay(50);
}
if(Button_state == HIGH) //If the button is pressed the buzzer is turned off and the detection too
{
detection = false;
digitalWrite(Buzzer, LOW);
}
}