
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Read Values Sent by Serial Monitor to Arduino
The Serial Monitor of Arduino has a text box at the top, through which, users can send in text to the Arduino board.
The text can be read by Serial.read(). Also, the Serial.available() function can be used to check if there is any data to read. It returns the number of characters or bytes available for reading, i.e., the number of bytes stored in the serial receive buffer.
Example
Using these functions, let’s create a simple echo program for Arduino. The code for the same can be found below −
void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println(); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()> 0){ char c = Serial.read(); Serial.print(c); } }
Over here, it is best that you check the Serial Monitor output for yourself. Try sending text to your board, and see it echo it back to you.
Output
Advertisements