problem with digitalwrite?, upload works!

I've got a strange problem over here so hope you guys can help.

After experimenting with some led's last week, today i wanted to play some more..

i opened the blink example again, uploaded it (RX TX and led 13 light up) also the arduino software gives me a done uploading message.

but after that message, nothing happens...

so i tried the serial ascii table example, uploaded it, opened the console, and i get the character output on screen.

so i know the code is uploaded correctly, but why don't i get digitalwrite to work???

hope you guys can help

but why don't i get digitalwrite to work???

How could we possible know that? You haven't posted the code yet for anyone else but yourself to be able to read it.

A common mistake is not doing the pinMode() statement, or not doing it correctly.

Lefty

ok that's true, sorry about that..

/* Blink

Turns on an LED on for one second, then off for one second, repeatedly.

The circuit: * LED connected from digital pin 13 to ground.

  • Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example.

Created 1 June 2005 By David Cuartielles

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board

*/

int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() { // initialize the digital pin as an output: pinMode(ledPin, OUTPUT); }

// the loop() method runs over and over again, // as long as the Arduino has power

void loop() { digitalWrite(ledPin, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(ledPin, LOW); // set the LED off delay(1000); // wait for a second }

uploaded it (RX TX and led 13 light up)

Check that the on time of the LED is not too long as you are not seeing it. A delay of 500 should be fine.

The other alternative is that you have blown pin 13, try it on another pin (not 0 or 1) with an external resistor and LED.

but if pin 13 would have blown then it shouldn’t light up when uploading right?

but just to be sure i tried 4 more pins, and they are all not working…

well here is a video of uploading the blink sketch...

after uploading nothing happens...

http://www.youtube.com/watch?v=XZIzlqZq_GE

Is the led still pin 13 on the mega? Might be a dumb question, but I've never used a mega.

  • LED connected from digital pin 13 to ground.

  • Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example.

This information is incorrect, if you are using an external LED you need an external resistor. Otherwise you run the risk of damaging the arduino or the LED.

The Mega still maps the on board LED to pin 13. What happens to the on board LED if you remove the external one.

This information is incorrect, if you are using an external LED you need an external resistor. Otherwise you run the risk of damaging the arduino or the LED.

The Mega still maps the on board LED to pin 13. What happens to the on board LED if you remove the external one.

the same as with a led connected, it blinks a few times together with the TX RX leds while uploading.

about the resistor, i know, but just a few blinks to check if it works won't kill it, right?

and if it would kill pin13, the other 53 pins should work, and they currently don't work...

btw, thanx for your ideas so far.

I added a video of uploading the blink example to the arduino without a led attached to pin 13, i filmed in the dark because with daylight the leds on the arduino are not noticeable on my crappy phone camera. the power led is on the left, the RX TX and onboard Led13 are on the right..

http://www.youtube.com/watch?v=YhoD3g8lyi8

but just a few blinks to check if it works won't kill it, right?

Yes I have to agree with you it could but probably won't.

Ok what happens when you press the reset button on the arduino, do you get any blinks then? It could be that some how the board is crashing somewhere.

Ok what happens when you press the reset button on the arduino, do you get any blinks then? It could be that some how the board is crashing somewhere

Ok tried reset, the led13 blinks 1 time very short, and that's it.

uploaded the example sketch again but still nothing...

also tried different USB ports...

This is most odd. Try putting this in:-

void loop()                    
{
 digitalWrite(ledPin, HIGH);   // set the LED on
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, LOW);    // set the LED off
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, HIGH);   // set the LED on
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, LOW);    // set the LED off
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, HIGH);   // set the LED on
 delay(1000);                  // wait for a second
 digitalWrite(ledPin, LOW);    // set the LED off
 delay(1000);                  // wait for a second
}

That is string out the loop.
Also try putting that lump in the setup code.
The other thing you could try is replacing the delay calls with a
for(int i =0; i<0xfffe; i++) { digitalWrite(ledPin+1, LOW); }
that gives you a delay without relying on the stuff in the delay function.

It might be that the arduino is crashing due to a faulty flash memory. Have you been playing with the watch dog timer? You could have this set to a really short value.

That is string out the loop.
Also try putting that lump in the setup code.
The other thing you could try is replacing the delay calls with a
for(int i =0; i<0xfffe; i++) { digitalWrite(ledPin+1, LOW); }
that gives you a delay without relying on the stuff in the delay function.

hmm tried it… still nothing…

It might be that the arduino is crashing due to a faulty flash memory.

that sounds really bad! :-[

Have you been playing with the watch dog timer? You could have this set to a really short value.

i haven’t got a clue what the watch dog timer is… i’ll search/have a look on the forum.

Sorry I have run out of ideas, it sounds like a broken processor or faulty crystal.

THANX for your help Mike

:’(

i’m on ebay now, searching for a new one…

if anybody got any other ideas…

I feel all sympathetic now :’(

Did it work to begin with?? I hope it’s not toast. It’s not so bad on the 328’s as you can swap the IC out. The mega’s, however, are not so fortunate.

regards.
pat

Hello again,

so i ordered a new Arduino Mega, got it today! so curious if it would work i connected it right away…

and WHAT THE H*LL, the blink sketch did NOT work… >:(

so i figured there must be something else wrong.

i downloaded the arduino software again, installed it
then installed the FTDI driver’s

and then a miracle happened: both the arduino’s work now!

so i’m very happy with 2 arduino mega’s

but i’m not sure what possibly could have been wrong with the FTDI driver?

anyway, this topic can be marked SOLVED :slight_smile:

What might happen from time to time is that unused (!) com ports are polled e.g. by backgroiund tasks or by the driver itself; by this DTR is generally toggled.

This would reset the Arduino in short intervalls, allowing the bootloader to permanently restart, but nothing else...

This changes as soon as the com port is in use, by the monitor (or the loader). This could have been a nice check: To just open the monitor and see whether Blink now run. Too late now!

Nevertheless, this is a remote hypothesis not better than others...