Go Down

Topic: STRING of 50 NUL (Read 527 times) previous topic - next topic

Richard Parsons

Need to send a string of 50 NUL to wake up printer: cannot not seem to get right code- Any ideas?


Code: [Select]
for (int i=0; i<50; i++) { Serial.write(0); } //maybe?

Richard Parsons

It worked using Serial.print but didn't seem to like write.   It woke up the printer
which then went to sleep again!  Very annoying!


Dec 02, 2010, 02:03 am Last Edit: Dec 02, 2010, 02:04 am by BKnight760 Reason: 1
Remember that null is not the same as ASCII zero.

0 ASCII= 48 decimal = 30 hex
null ASCII = 0 decimal = 00 hex

Serial.print(0); will print out an ASCII zero, not a null.
Serial.write(0); *should* get you a null character.

To be sure, you could try:
Code: [Select]

char MyNullCharacter=0x00;
for (int i=0;i<50;i++)

That way, you set the character equal to hex 00, which is null for sure.


Dec 02, 2010, 04:57 pm Last Edit: Dec 02, 2010, 04:59 pm by robtillaart Reason: 1
@Richard you asked this also in another thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290618777 and thats called crossposting and some people don't like that as it costs double time For you to write the message, for us to read them, for you to collect answers etc.  I added a message that the discussion is continued in this thread.

Wrt the question, where does the 50 nulls come from? Could you please place a copy of that manual page here? Maybe it need a few more bytes, a checksum, a certain baudrate ?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up