Code is getting Uploaded but nothing works

Board is turning on, My Computer recognizes the device, Code gets uploaded, Rx led flashes while uploading and L led flashes if i press the reset button.
but my arduino nano doesn't seem to execute the code.
tried checking voltages with a multimeter on 5V and 3.3V. Voltages are perfect.
the defined buzzerPin reads 1.1V and the signalPin reads 0.5V to 0.6V
tried checking the voltages in other digital Pins everything seems to be nominal.
But nothing works as per the code.

const int buzzerPin = 2; // Define the pin for the buzzer
const int signalPin = 3; // Define the pin for the signal input
unsigned long duration = 5000; // Set the duration (in milliseconds) the buzzer will stay on
bool buzzerActive = false; // Flag to keep track of buzzer state

void setup() {
  pinMode(buzzerPin, OUTPUT);
  pinMode(signalPin, INPUT);
}

void loop() {
  int signal = digitalRead(signalPin);

  if (signal == HIGH && !buzzerActive) {
    // If signal is received and buzzer is currently off
    digitalWrite(buzzerPin, HIGH); // Turn on the buzzer
    delay(duration); // Keep it on for the set duration
    digitalWrite(buzzerPin, LOW); // Turn off the buzzer
    buzzerActive = true; // Set the flag to indicate buzzer is active
  }

  if (signal == LOW && buzzerActive) {
    buzzerActive = false; // Reset the flag when the signal goes low
  }
}

Welcome to the forum

What messages do you see in the window at the bottom of the IDE when you upload the code ?

Try uploading the Blink example with nothing connected to the Nano

1 Like

What do you have connected to the Arduino?

Post links and a wiring diagram (hand drawn is preferred).

2 Likes

Thank you.
The Usual sketch messages. no errors
Tried Uploading the Blink Example code gets uploaded But its not working.

Hello sknmusic

Welcome to the best Arduino forum ever.

What type of buzzer you are using?

A passive or active one?

Replace the buzzer by a LED with resitor to see what happens.

1 Like

Thank You.
I have connected the arduino nano with a USB Cable to power and upload the code
and i have a buzzer +ve connected to the digitalPin 2 and -ve connected to the GND of the nano.
a bare wire connected to the digitalPin 3 which in my case is signalPin.
working to get a diagram.

Please post those messages in full for the Blink example

1 Like

Thank You.
I'm using a passive buzzer.
Tried connecting a LED but the LED doesn't work also.

Thank You.

Try turning on "Verify code after upload", upload the Blink sketch and post the full output from the bottom window. You can select it all with the mouse and copy it into code tags when you post it here

2 Likes

Thank you.

`Sketch uses 924 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM8" -b115200 -D "-Uflash:w:C:\Users\AppData\Local\Temp\arduino\sketches\8FED38077867166EEE730D3AF3190DBF/Blink.ino.hex:i"

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\KAR-98K\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

     Using Port                    : COM8
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200
     AVR Part                      : ATmega328P
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PC2
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
       flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
       lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : Arduino
     Description     : Arduino
     Hardware Version: 3
     Firmware Version: 4.4
     Vtarget         : 0.3 V
     Varef           : 0.3 V
     Oscillator      : 28.800 kHz
     SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\KAR-98K\AppData\Local\Temp\arduino\sketches\8FED38077867166EEE730D3AF3190DBF/Blink.ino.hex"
avrdude: writing flash (924 bytes):

Writing | ################################################## | 100% 0.13s

avrdude: 924 bytes of flash written

avrdude done. Thank you.`

I can't see anything wrong but others may spot something

1 Like

Thanks for your much appreciated time.
This is my first time using arduino and a forum post.
Should i try flashing the BOOTLOADER?

I would not flash the bootloader.
Is this device genuine Arduino or some clone (w/ a CH340)?

Haven't uploaded to a 'Classic Nano' in a long time, but we always used to upload it as a Duemilanove.

I'm not a IDE2.x user.
Are those 'information' symbols par for the course - indicating 'Success' ?

image

1 Like

No, the Nano I'm using is a clone with a CH340.
Yes, the notifications mean that the process is a success!
Thank You.

Problem uploading to CH340 Nano - Using Arduino / Avrdude, stk500, Bootloader issues - Arduino Forum

1 Like

I think it's the CH340 driver.
The 2019 version is needed (the 2023 is a bust).

Uploading failure on Arduino Nano with CH340 chip - Nano Family / Classic Nano - Arduino Forum

1 Like

Actually, your reply to that post is true. I tried using the old IDE and it just threw some error messages just like the one posted there.

But for me the code gets uploaded successfully but it's not working.
please review my reply prior to your reply if that can give you some clarity on my specific problem it'll be great.

Thanks.

My nano was working fine like 3hrs ago.
I disconnected the USB Cable as usual and left it in the breadboard where i have the components connected.
When i came back and tried powering on the nano like usual nothing seems to work.

Searching Nano + CH340
turns up lots of problems.
A couple had the request to click the Reset button
and observe the 'L' status - which the OP's never replied to, sadly.
I'm aware of problems, but a solid "root cause" Solution I have not seen.

@ptillisch ??

1 Like