Pages: [1]   Go Down
Author Topic: send port register status over serial  (Read 313 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm wondering if there is a way to send the status of a port register over serial directly, i.e. send PIND as one byte and NOT a collection of bytes representing the ASCII values of whatever that number happens to be. Serial.print() and Serial.println() seem to only be good for sending ASCII representations of data, unless there's something I'm not understanding (which seems pretty likely!)

Thanks,
Cameron
« Last Edit: December 12, 2007, 08:32:02 pm by ncbritt » Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 572
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you check the Reference page for the Serial.print command?

http://www.arduino.cc/en/Serial/Print

The

Code:
Serial.print(b, BIN);

and

Code:
Serial.print(b, BYTE);

command seem like they might be what you are looking for.

Logged

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

Thanks. Serial.print(b, BYTE) actually did the trick. I was misunderstanding the help file and was worried that Max was going to interpret the number it received over serial as some ASCII value, but it worked just casting it as an int in Max.

If I sent a byte with Serial.print(b, BIN) the computer would actually receive bytes: one each for the 0 or 1 needed to represent the 8 bits of my byte.

Logged

Pages: [1]   Go Up
Jump to: