Pages: [1]   Go Down
Author Topic: Arduino Nano resets every 30 seconds  (Read 1005 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm new in Arduino, but have some basics in electronics and programming. My question is very simple and so I hope the solution.

I'm using Arduino Nano 3.0 with ATMega328 on it. I just want a LED to be on forever, with this simple code:

int led = 13;
void setup() {               
pinMode(led, OUTPUT);     
}
void loop() {
digitalWrite(led, HIGH); 
}

Very easy! But here is the problem: my board resets about every 30 seconds and so the LED goes off for a while and then switch on again. For my application, this is not acceptable !!!!

Hope somebody can help me.

Gabriele
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26285
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you just want to light a LED, you don't need a microcontroller.
How are you powering this device?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
my board resets about every 30 seconds and so the LED goes off for a while
So you have to find out what is causing it.
The information supplied so far doesn't contain any thing that you are doing wrong. So you need to supply more information.

What arduino do you have?
Have you previously set up the watchdog timer?
Is there anything that can cause interference close by, like motors, florescent lights, thermostats?
Have you got a series resistor in line with your LED?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To AWOL: my application is actually more complicated, as it involves also a buzzer and an external LED, but the problem stays. I'm powering it form USB.

To Grumpy_Mike: I tried to disable watchdog as following, but the problem remains:

#include <avr/wdt.h>
int led = 13;
ISR (WDT_vect)
{
   wdt_disable();
}

void setup() {               
pinMode(led, OUTPUT);     
}
void loop() {
digitalWrite(led, HIGH); 
}

I tried also just putting command wdt_disable in the void loop() but doesn't solve the problem!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To Grumpy_Mike: I have an Arduino Nano V.3.0 with ATMega328 with no interferences around. I'm using LED already on the board for now, with a series resistor, but I have the same problem even with a buzzer connected to a digital Pin: the board simply resets all alone!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I read this in the product page of Arduino Nano on Arduino website: maybe it can be of some help, but I don't understand exactly what it means.

Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the Arduino Nano is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of the FT232RL is connected to the reset line of the ATmega168 or ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the bootloader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the Nano is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Nano. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.
[/i]
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK what system are you running it from?
Some Linux systems keep opening up the serial port and this resets the arduino automatically.

Try opening up the serial monitor, that will hold open the serial port drivers. If that stops it resetting then that is the problem.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear Grumpy_Mike that works!!!!

Keeping the serial monitor open eliminates the problems and the board doesn't reset anymore.

Is there a way to avoid it without keeping the serial monitor open? (I'm running windows 7 by the way)

I guess that when I'll be supplying my board with an external voltage different from the USB the problem won't appear, right?

Thank you very much sincerely!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I guess that when I'll be supplying my board with an external voltage different from the USB the problem won't appear, right?
That's right.

Quote
Is there a way to avoid it without keeping the serial monitor open?
I don't know, that is a windows question and I am a Mac man.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok thanks again!
Logged

Pages: [1]   Go Up
Jump to: