i was working back my program and couldn't find the cause of the problem, so i loaded up the Blink example, and that worked fine, then i added Serial.begin(9600); in the setup loop and upload it, and the LED doesn't blink.
if i comment out the serial line it works again.
i have tried this on two different arduinos (arduino nano, 328 chip)
its not exactly complex code, its as i said, the blink example but with the added line of Serial.begin
but here is the code:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
Do you have anything at all connected to the Arduino except the USB lead to the PC? If not, I'd be looking for errors in the way the sketch was uploaded or the Arduino was powered.
Have you tried commenting the Serial.begin() out, verifying and uploading and just prove that it then starts blinking as normal?
PeterH:
Do you have anything at all connected to the Arduino except the USB lead to the PC? If not, I'd be looking for errors in the way the sketch was uploaded or the Arduino was powered.
Have you tried commenting the Serial.begin() out, verifying and uploading and just prove that it then starts blinking as normal?
nothing at all connected to the arduino,
if i comment out or remove the Serial.begin line then it uploads and runs fine
also if i add to the void loop: Serial.println("test");
i get "test" in the debug window every second, but the LED is not flashing. so that proves that the arduino is running and hasn't locked up. removing all serial references proves that the LED is working.
i have no idea what could be causing this or why it would happen on two different arduinos, but it seems to be the cause of hours of bug hunting.
i have changed to IDE 1.0.1 and it seems to be working now, so there may have been a problem with my 1.0.0 install
but i thought it might be worth mentioning a little more about my previous program that i was trying to debug,
it was using the interrupt on pin 2, and a couple of time when trying to activate it, it went into a loop and got stuck. maybe something in volatile memory got corrupted,
also i was using two arduinos on the same computer just on different com ports, which may have had some effect.
anyway i am going to progress further but at the moment it seems to work thanks