This is the 12th lesson of Arduino tutorial. So, in the previous post, we have talk about how to work with potentiometer using Arduino. In this lesson we are going to learn how to work with serial monitor of Arduino. Let’s get started.
What is Arduino seral monitor?
Arduino serial motor is simply a way to show Arduino data.
That means you don’t have to set an output device like LED in Arduino. You can
get the data what you wanted to your computer screen. It’s very efficient way
of output because LEDs can’t give exact output. You can get exact sensor data, digital
outputs using this serial monitor.
To work with serial monitor you don’t have to install any
software. It’s a part in Arduino IDE. Let’s see the code. In this circuit. You don’t
have to set any input or output devices.
In this code, I initialized serial motor as 9600 baud rate. Baud
rate stands for data rate in bits per second. Arduino’s default baud rate is
9600. We must mention the baud rate when working with serial motor because this
communication between microcontroller ad PC. In the void loop, I put “Serial.print(“SoftEXS”)”
line. “Serial.print” means print something in the serial monitor. Press the
start simulation button in the above iframe and then click the code button. In
the code window, there is an option called serial monitor. You can click that
and test how this is going to work. You can write anything inside the brackets
where I put “SoftEXS”.
In above method, it puts output again and again in the one
line. So, to prevent this thing, you have to put “Serial.println(“SoftEXS”)” then
it will print the output with line break. “ln” is like pressing enter button. You
can use those both function at the right places in your projects.
Arduino Potentiometer with Serial Monitor (Analog read in
Arduino Serial Monitor)
In this code, we are going to make an output from potentiometer
using Arduino. You have to make the circuit like below to do this.
First, we mentioned an integer named value to assign potentiometer
value. In this code’s void setup, we initialized Serial motor’s baud rate. Then
we mentioned “A0” pin as input. Inside the void loop, we assigned A0 pin readings
(potentiometer values) to variable named value. In the 2nd line of
void loop, we put “Serial.println” and inside it, we put the value (A0 pin’s readings).
Then in the last line there is a delay for easy ness to read the value.
Arduino Switch with Serial Monitor (Digital read in Arduino
Serial Monitor)
In this code, we add a variable named “var” to assign
digital reading of switch. In the void setup, as I mention above, I initialized
Serial monitor’s baud rate is for 9600. Then I mentioned 2nd pin of the
Arduino as Input. Inside the void loop, I assigned digital read value of 2nd
pin to variable named var. then in the second line of the void loop, I print
the “var”.