Why my project does not work until I charged the laptop connected with arduino?

I am trying to make a project which the piezo buzzer is controlled by the photo resistor. while it does not work with 9v battery or connected with my laptop until the laptop is charging.

Does it mean that the voltage is not enough? while I dont know why it happens, since I feel like the buzzer and photo resistor I use in this project dont require really high voltage?


Thank you so much!

my project is just like this:

like an alarm

Hello Anrn.

while it does not work with 9v battery

did you soldered the wires directly to the Arduino.? If "YES" Please re-check connections, if "NO" or using the barrel jack pin, check the battery voltage, look for it's charge.

connected with my laptop until the laptop is charging.

Try changing the USB port, maybe that port is internally damaged.??

Thank you

@Anrn, post the program you have uploaded to your Arduino and also make a simple pencil drawing showing how YOU have everything connected and post a photo of the drawing.

...R

Robin2:
@Anrn, post the program you have uploaded to your Arduino and also make a simple pencil drawing showing how YOU have everything connected and post a photo of the drawing.

…R

@Robin2

This is how I connected the wire. I use a 10k resistor connected to the photo resistor and a 220 resistor connected to the piezo buzzer.

my coding:

const int buzzerPin=12;
const int ldrPin_C=A0;

#define NOTE_C 882

void setup() {

Serial.begin(9600);
pinMode(buzzerPin,OUTPUT);
pinMode(ldrPin_C, INPUT);

}

void loop() {

int ldrStatus_C=analogRead(ldrPin_C);

Serial.println(ldrStatus_C);

if(ldrStatus_C>=10){
tone(buzzerPin,NOTE_C);
delay(100);

noTone(buzzerPin);

}
else{noTone(buzzerPin);}

}

Thank you!

mudassir9999:
Hello Anrn.

did you soldered the wires directly to the Arduino.? If "YES" Please re-check connections, if "NO" or using the barrel jack pin, check the battery voltage, look for it's charge.
Try changing the USB port, maybe that port is internally damaged.??

Thank you

Hi, I didn't solder the wires directly to the arduino. and I tried other 9v battery using barrel jack pin and change the usb port, still doesnt work. :frowning:

Image from Reply #4 so we don’t have to download it. See this Image Guide

c6b9063396ddaa75a72a4fb08136ce42f53333e6.png

…R

That does not look like the simple pencil drawing I requested. I am never confident that a Fritzing diagram shows things properly.

One thought is that the GND connection may not be continuous across the breadboard. Many of them have a gap in the middle.

...R