Serial.write Teensyduino question.

Status
Not open for further replies.

mixographer

New member
Serial.print seems to work for me, but Serial.write doesn't.

Teensyduino 1.16 on a Mac.

Should this work?

Code:
void setup(){
    Serial.begin(9600);
}


void loop(){
  byte controlByte = B00000001;
  Serial.println("hello:");
  Serial.write( controlByte);
  delay(500);  
}


I get:

Code:
hello:
hello:
hello:


in my Serial monitor
Am I doing something wrong?
 
Serial.write(1) sends the binary value 1, this is a nonprinting character.
Serial.print(1) converts the number 1 to its text representation "1", ascii character for 1,
and send this as a byte with numerical value 49.

So your code is doing what is supposed to, the binary value 1 is not shown in your text window.
 
Status
Not open for further replies.
Back
Top