mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Modifying examples to use Serial.write() instead of Serial.print(BYTE).
This commit is contained in:
parent
e031022a68
commit
6739f20bbf
@ -38,7 +38,7 @@ void loop()
|
|||||||
// prints value unaltered, i.e. the raw binary version of the
|
// prints value unaltered, i.e. the raw binary version of the
|
||||||
// byte. The serial monitor interprets all bytes as
|
// byte. The serial monitor interprets all bytes as
|
||||||
// ASCII, so 33, the first number, will show up as '!'
|
// ASCII, so 33, the first number, will show up as '!'
|
||||||
Serial.print(thisByte, BYTE);
|
Serial.write(thisByte);
|
||||||
|
|
||||||
Serial.print(", dec: ");
|
Serial.print(", dec: ");
|
||||||
// prints value as string as an ASCII-encoded decimal (base 10).
|
// 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
|
// plays a MIDI note. Doesn't check to see that
|
||||||
// cmd is greater than 127, or that data values are less than 127:
|
// cmd is greater than 127, or that data values are less than 127:
|
||||||
void noteOn(int cmd, int pitch, int velocity) {
|
void noteOn(int cmd, int pitch, int velocity) {
|
||||||
Serial.print(cmd, BYTE);
|
Serial.write(cmd);
|
||||||
Serial.print(pitch, BYTE);
|
Serial.write(pitch);
|
||||||
Serial.print(velocity, BYTE);
|
Serial.write(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,6 @@ void loop() {
|
|||||||
// read from port 1, send to port 0:
|
// read from port 1, send to port 0:
|
||||||
if (Serial1.available()) {
|
if (Serial1.available()) {
|
||||||
int inByte = Serial1.read();
|
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
|
// read switch, map it to 0 or 255L
|
||||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||||
// send sensor values:
|
// send sensor values:
|
||||||
Serial.print(firstSensor, BYTE);
|
Serial.write(firstSensor);
|
||||||
Serial.print(secondSensor, BYTE);
|
Serial.write(secondSensor);
|
||||||
Serial.print(thirdSensor, BYTE);
|
Serial.write(thirdSensor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void establishContact() {
|
void establishContact() {
|
||||||
while (Serial.available() <= 0) {
|
while (Serial.available() <= 0) {
|
||||||
Serial.print('A', BYTE); // send a capital A
|
Serial.print('A'); // send a capital A
|
||||||
delay(300);
|
delay(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ void stringCallback(char *myString)
|
|||||||
|
|
||||||
void sysexCallback(byte command, byte argc, byte*argv)
|
void sysexCallback(byte command, byte argc, byte*argv)
|
||||||
{
|
{
|
||||||
Serial.print(START_SYSEX, BYTE);
|
Serial.write(START_SYSEX);
|
||||||
Serial.print(command, BYTE);
|
Serial.write(command);
|
||||||
for(byte i=0; i<argc; i++) {
|
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()
|
void setup()
|
||||||
|
@ -71,7 +71,7 @@ void loop() {
|
|||||||
thisChar = 'a';
|
thisChar = 'a';
|
||||||
}
|
}
|
||||||
// print the character
|
// print the character
|
||||||
lcd.print(thisChar, BYTE);
|
lcd.write(thisChar);
|
||||||
// wait a second:
|
// wait a second:
|
||||||
delay(1000);
|
delay(1000);
|
||||||
// increment the letter:
|
// increment the letter:
|
||||||
|
@ -61,7 +61,7 @@ void loop() {
|
|||||||
// set the cursor position:
|
// set the cursor position:
|
||||||
lcd.setCursor(thisRow,thisCol);
|
lcd.setCursor(thisRow,thisCol);
|
||||||
// print the letter:
|
// print the letter:
|
||||||
lcd.print(thisLetter, BYTE);
|
lcd.write(thisLetter);
|
||||||
delay(200);
|
delay(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user