Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more. Accepting essential orders - here's how.
0

AFSoftSerial questions
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

AFSoftSerial questions

by zlite on Sun Jul 06, 2008 12:54 pm

I'm having a little trouble using AFSoftSerial to read GPS strings and have two questions:

1) Why do the examples always tend to use pin 2 and 3 for Rx and Tx? Those are the hardware serial pins--exactly the ones you don't need for software serial.

2) Can you use any digital pins for Rx and Tx?
zlite
 
Posts: 9
Joined: Sun Jul 06, 2008 12:47 pm

by mtbf0 on Sun Jul 06, 2008 1:57 pm

uh, 0 and 1 are hardware rx and tx.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by zlite on Sun Jul 06, 2008 2:03 pm

Are you referring to the physical pins or logical pins? According to the official pin mapping the Rx and Tx are on physical pins 2 and 3. Those are of course digital pins 0 and 1.

So the AFSoftSerial is assuming that the pin number refer to logical pins, and "2" and "3" are actually physical pins 4 and 5?
zlite
 
Posts: 9
Joined: Sun Jul 06, 2008 12:47 pm

by mtbf0 on Sun Jul 06, 2008 4:30 pm

yes. which is to say i don't know because all my arduini are boarduini and rbbb's, but the 2 and 3 refer to digital pin 2 and digital pin 3.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by adafruit on Sun Jul 06, 2008 4:59 pm

like all arduino libraries, the pins indicated are the digital pin names, not 'actual' pin names

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by zlite on Sun Jul 06, 2008 6:55 pm

ladyada wrote:like all arduino libraries, the pins indicated are the digital pin names, not 'actual' pin names


Many thanks for the clarification on that, which I've been confused by from the start. I wonder what to do with functions that can use both analog or digital pins--I guess you have to refer to the analog ones by their "official" names, such as PC0?
zlite
 
Posts: 9
Joined: Sun Jul 06, 2008 12:47 pm

by mtbf0 on Sun Jul 06, 2008 7:21 pm

zlite wrote:
ladyada wrote:I guess you have to refer to the analog ones by their "official" names, such as PC0?


no. don't do that. when using them for digital i/o they are digital 14-19. PC0 is a constant that indicates pin number 0 in portC. so if you were to use, for instance

Code: Select all | TOGGLE FULL SIZE
digitalWrite (PC0, HIGH);

it would be the same as if you'd used

Code: Select all | TOGGLE FULL SIZE
digitalWrite(0, HIGH);

and you'd be writing a 1 to digital pin 0, the receive pin for the hardware serial interface.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

by zlite on Sun Jul 06, 2008 7:26 pm

Many thanks for the clarification--I don't know how I missed that so far, but this will save me many baffling bugs going forward.
zlite
 
Posts: 9
Joined: Sun Jul 06, 2008 12:47 pm

Please be positive and constructive with your questions and comments.