Created
September 27, 2017 03:07
-
-
Save lazytomatolab/a176df60423aa2db63a3c3ebec878d4b to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 11 - Serial monitor 讀心術!更多資訊請造訪:http://www.lazytomatolab.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(115200); | |
Serial.println("Hello! This is LazyTomato Lab!"); | |
delay(1000); | |
Serial.println("Please visit: http://www.lazytomatolab.com/"); | |
} | |
void loop() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int universe = 42; | |
void setup() { | |
Serial.begin(115200); | |
Serial.print("The answer to life, the universe, and everything: "); | |
Serial.print(universe); | |
Serial.print("."); | |
} | |
void loop() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
if(Serial.available()) { | |
int num = Serial.parseInt(); | |
Serial.print("The temperature is: "); | |
Serial.print(num * 9 / 5 + 32); | |
Serial.println(" °F"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(115200); | |
pinMode(13, OUTPUT); | |
digitalWrite(13, LOW); | |
} | |
void loop() { | |
if(Serial.available()) { | |
char ch = Serial.read(); | |
if(ch == 'O') { | |
digitalWrite(13, HIGH); | |
} | |
else if(ch == 'C') { | |
digitalWrite(13, LOW); | |
} | |
else { | |
Serial.println("Invalid character."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment