Modifying examples to use Serial.write() instead of Serial.print(BYTE).

This commit is contained in:
David A. Mellis 2011-02-26 13:57:41 -05:00
parent e031022a68
commit 6739f20bbf
7 changed files with 15 additions and 15 deletions

View File

@ -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).

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -14,12 +14,12 @@ void stringCallback(char *myString)
void sysexCallback(byte command, byte argc, byte*argv)
{
Serial.print(START_SYSEX, BYTE);
Serial.print(command, BYTE);
Serial.write(START_SYSEX);
Serial.write(command);
for(byte i=0; i<argc; i++) {
Serial.print(argv[i], BYTE);
Serial.write(argv[i]);
}
Serial.print(END_SYSEX, BYTE);
Serial.write(END_SYSEX);
}
void setup()

View File

@ -71,7 +71,7 @@ void loop() {
thisChar = 'a';
}
// print the character
lcd.print(thisChar, BYTE);
lcd.write(thisChar);
// wait a second:
delay(1000);
// increment the letter:

View File

@ -61,7 +61,7 @@ void loop() {
// set the cursor position:
lcd.setCursor(thisRow,thisCol);
// print the letter:
lcd.print(thisLetter, BYTE);
lcd.write(thisLetter);
delay(200);
}
}