Arduino Serial monitor
Serial Monitor is a component of the Arduino IDE. It can use
- Show results from Arduino boards.
- receive data from user and send data to the Arduino board.
- Show results from Arduino boards.
- receive data from user and send data to the Arduino board.
How to use?
Setup baud rate
Setup baud rate
void setup()
{
Serial.begin(9600);
}
Show results in Serial Monitor{
Serial.begin(9600);
}
Serial.print("Hello World"); /* Show Hello World */
Serial.println("Hello World"); /* Show Hello World And New Line */
Read data from Serial Monitor
Serial.println("Hello World"); /* Show Hello World And New Line */
Serial.read();
How to open Serial Monitor
1. Ctrl + Shift + M
2. Click Icon
Example - Show data to Serial Monitor
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(9600); | |
} | |
void loop() | |
{ | |
Serial.println("Hello World"); | |
delay(1000); | |
} |
Output the program
Example - Read data from Serial Monitor
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(9600); | |
pinMode(LED_BUILTIN,OUTPUT); | |
} | |
void loop() | |
{ | |
if (Serial.available()) | |
{ | |
char c = Serial.read(); | |
if (c == '1') | |
{ | |
Serial.println("On LED"); | |
digitalWrite(LED_BUILTIN,HIGH); | |
} | |
else | |
{ | |
Serial.println("Off LED"); | |
digitalWrite(LED_BUILTIN,LOW); | |
} | |
} | |
} |
- Sent 1 On LED
- Sent 0 Off LED
Output Read data from Serial Monitor
* If Unsuccessful Check that selected: No line ending And : 9600 baud?
Comments
Post a Comment