Loading...
Pages: [1]   Go Down
Author Topic: UCSRB = 0;   Pins 0 and 1 as I/O  (Read 536 times)
0 Members and 1 Guest are viewing this topic.
Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Can we put the "UCSRB = 0;" info for disabling the serial port into the reference docs? I had a few students who were having trouble with this...

thanks

D
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe it's better to add a Serial.end() function that does the same thing?  And making pins 0 and 1 available as digital i/o if Serial.begin() hasn't been called?
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

we couldn't get pin 0 and/or 1 to act as regular I/O, without any serial commands at all. As soon as we put the "UCSRB=0" line in, they magically came to life, or at least they could be addressed with digitalWrite()... but maybe we're doing something wrong?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 7
Posts: 3532
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're not doing anything wrong.  But we could have the Arduino core automatically disconnect the serial connection from pins 0 and 1 (so you can use them as regular digital i/o) when your sketch starts (since the bootloader was using the serial connection, the pins are, I think, already configured that way).  That is, I should put UCSRB=0; into main() before the call to setup().
Logged

Rochefort, France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino is a king
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry, but this doesn't work for me.
when i add UCRSB = 0; in setup() i get an error message. the same is true also for Serial.end ()
please tell what to do to activate pin 0 and 1 so digitalWrite may work!!!!!!
thanks for your help.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset


You wil get an error if the UCSRB = 0; statement isn't inside of void setup().

You have it mistyped in your post, check that it's correct in your code. You've got
UCRSB = 0;

which should actuallly be
UCSRB = 0;

In Arudino 7 it is implemented by default-- i.e. the digital pins on 0 and 1 are available without the above command.
D

« Last Edit: January 28, 2007, 01:47:45 pm by Daniel » Logged

Rochefort, France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino is a king
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i downloaded version 7.
now pins 0 and 1 work like a charm!
thanks.
Logged

Pages: [1]   Go Up
Print
 
Jump to: