mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Modifying examples to use Serial.write() instead of Serial.print(BYTE).
This commit is contained in:
@ -38,7 +38,7 @@ void loop()
|
||||
// prints value unaltered, i.e. the raw binary version of the
|
||||
// byte. The serial monitor interprets all bytes as
|
||||
// ASCII, so 33, the first number, will show up as '!'
|
||||
Serial.print(thisByte, BYTE);
|
||||
Serial.write(thisByte);
|
||||
|
||||
Serial.print(", dec: ");
|
||||
// prints value as string as an ASCII-encoded decimal (base 10).
|
||||
|
@ -42,8 +42,8 @@ void loop() {
|
||||
// plays a MIDI note. Doesn't check to see that
|
||||
// cmd is greater than 127, or that data values are less than 127:
|
||||
void noteOn(int cmd, int pitch, int velocity) {
|
||||
Serial.print(cmd, BYTE);
|
||||
Serial.print(pitch, BYTE);
|
||||
Serial.print(velocity, BYTE);
|
||||
Serial.write(cmd);
|
||||
Serial.write(pitch);
|
||||
Serial.write(velocity);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,6 @@ void loop() {
|
||||
// read from port 1, send to port 0:
|
||||
if (Serial1.available()) {
|
||||
int inByte = Serial1.read();
|
||||
Serial.print(inByte, BYTE);
|
||||
Serial.write(inByte);
|
||||
}
|
||||
}
|
||||
|
@ -52,15 +52,15 @@ void loop()
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.print(firstSensor, BYTE);
|
||||
Serial.print(secondSensor, BYTE);
|
||||
Serial.print(thirdSensor, BYTE);
|
||||
Serial.write(firstSensor);
|
||||
Serial.write(secondSensor);
|
||||
Serial.write(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.print('A', BYTE); // send a capital A
|
||||
Serial.print('A'); // send a capital A
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user