Pages: [1]   Go Down
Author Topic: Serial hangs after digitalWrite()  (Read 813 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hope I post to the right forum...

In order to be able to debug my programm I have disabled auto reset as described here: (http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection)

This works BUT hangs when my programm execute the line:
digitalWrite();

I then have to navigate to Tools->Serial Port and choose again my serial port
Then I am able to choose Serial Monitor again and to see the output (arduino doesnt hangs).

I am using UNO v3 connected to http://www.amazon.com/gp/offer-listing/B0057OC5O8/ref=dp_olp_new_mbc?ie=UTF8&condition=new

Any points?

Regards,

Maoz
Logged

Cumming, GA
Offline Offline
Edison Member
*
Karma: 18
Posts: 1627
Ultimate DIY: Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You have left out a lot of information.

1) Posting your code always helps
2) Why do you need to disable auto-reset?
3) digitalWrite(pin,value) is the correct format, but you are not showing us the PIN or VALUE you use to make it fail.
4) Debugging is designed to work over the serial connection and there is seldom a case where the reset that occurs creates hassle.

 
Logged

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

Thanks for answering

2) I want to debug my program from time to time. The arduino controls an engine (depends on weather) and I need to see the output from time to time and it should be continuous. If I won't use it then connecting reset my UNO... :-(

3) Well...
Code:
#define UP_OUTPUT 8
#define DOWN_OUTPUT 7

void goUP() {
  digitalWrite(UP_OUTPUT, LOW);
  delayMicroseconds(100);
  digitalWrite(DOWN_OUTPUT, HIGH);
  if(debug==1) {
    Serial.println("moveUP");
  }
}


The last output i see over serial is "moveUP", then if I reconnect (serial port) then I can see it wasn't hanged.

regards,

Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code snippets are rarely useful.

The problem isn't there.  Post all your code.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Enough power,  and right way to power up your devices?

Cheers,
Kari
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4554
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

3) Well...
Code:
#define UP_OUTPUT 8
#define DOWN_OUTPUT 7

void goUP() {
  digitalWrite(UP_OUTPUT, LOW);
  delayMicroseconds(100);
  digitalWrite(DOWN_OUTPUT, HIGH);
  if(debug==1) {
    Serial.println("moveUP");
  }
}


The last output i see over serial is "moveUP", then if I reconnect (serial port) then I can see it wasn't hanged.


Seems like a power problem to me. Whatever is connected to pin 7 does something bad when you turn it on.

In general there's no way Serial.println() can hang.
Logged

No, I don't answer questions sent in private messages...

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10445
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So the pin controls an engine.  That's going to take at a guess a relay?  You have separate power for the relay?  Proper protection diode?
Logged

[ I won't respond to messages, use the forum please ]

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4554
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The simple way to find out is to disconnect whatever it is and see if it still hangs.
Logged

No, I don't answer questions sent in private messages...

Pages: [1]   Go Up
Jump to: