Go Down

Topic: send port register status over serial (Read 392 times) previous topic - next topic

ncbritt

Dec 13, 2007, 02:31 am Last Edit: Dec 13, 2007, 02:32 am by ncbritt Reason: 1
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

trialex

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

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

The

Code: [Select]
Serial.print(b, BIN);

and

Code: [Select]
Serial.print(b, BYTE);

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


ncbritt

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.


Go Up