arduino serial monitor in tinkercad
The serial monitor is a way to report to the computer what is happening in the code via a USB cable.
In the Tinkercad circuit simulator, the serial monitor can be found at the bottom of the code panel, or it can be used to draw the variable diagram when the variable changes.
Use the serial monitor to \"talk\" to your computer to check if the Arduino code is performing as you expect.
This is very useful for solving code problems (
Called \"serial debugging \").
The two circuits in this lesson use the same configuration as the previous two lessons, namely, digital input with buttons and analog input with potentiometer.
The only difference is that these circuits are free. wired (no breadboard)
External LED is not connected.
Oh, they are running the code that generates the serial message and we will learn about this in this lesson.
You can almost use Tinkercad Circuits.
You can even get from Tinkercad (
Free login required)!
Explore the sample circuit and build your own circuit next to it.
Tinkercad Circuits is a free browser
You can build and simulate the program-based circuit.
It is perfect for learning, teaching and prototyping.
Let\'s use the code block editor to listen to the Arduino input pin and print out the value (analog)or state (digital)
Input in the serial monitor window.
Click the code button to open the code panel.
Click on the serial monitor at the bottom of the code panel.
Click Start simulation to run the Arduino sample code and observe the numbers in the serial monitor when interacting with the potentiometer.
When the simulation runs in the Tinkercad circuit, you can click back and forth between the two Arduinos, but only the analog circuit will be displayed in the embedded module above.
After copying the sample circuit to the Tinkercad account, you can change the code.
Navigate to the output code category, then drag out a \"print to serial monitor\" block and place it before the serial block that already exists in the program.
Change the default text to Mark serial data such as \"sensor :\"(
Don\'t forget the space after the colon)
, And adjust the drop-down menu to print without a new line.
Start the simulation and observe the changes in the serial monitor.
You can stack serial blocks like this in order to create useful feedback messages when developing any project code.
When opening the code editor in the Tinkercad circuit, you can click the drop-down menu on the left and select \"block text\" to display the Arduino code generated by the code block (
The first step is not available in the embedded module).
This code sends data from Arduino to serial monitor, but in later lessons you can also learn how to receive data from serial monitor and bi-directional serial communication.
Before setting ()
We can see more than one.
A line note that begins with/* and ends.
At the beginning of our program, we will create a variable to save the state of the input.
Inside the settings, as in the analog and digital input course, the pins connected to the switch or sensor are configured to use the input of pinMode ()function.
In order to be able to send a message, Arduino needs to work with S.
Just like pressing the call button on the phone
From that moment on, you have opened a communication line for the phone.
This parameter tells the speed of Arduino communication, for example, 9600 bits per second (aka baud).
The code in the loop reads the input status with digitalRead ()
And store it in the button state variable.
Then a function called S sends the data to the monitor (
Via USB cable in case of physical Arduino board).
If you make a block change to the program in the previous step, you will also have line S code.
Println sent a new line after the message, no print.
For example, use quotation marks around text labels.
If you want to do a line of serial debugging output, you can use a few S commands and then an S command.
There is a special function in the Tinkercad circuit called the debugger.
It can go through your code step by step, allowing you to look at your variables and so on.
After opening the code editor, click the button with the bug icon to find the debugger.
In block text mode (or Text-
Only mode, if you like)
, Click the line number to add a breakpoint, and the debugger will stop in each loop.
Start the simulation.
Hover your mouse over variables while you pause to see their values.
These circuits can be used as circuit starters.
You can use these circuit starters at any time to read digital or analog inputs and print their status to a serial monitor.
Grab the Arduino circuit starter from the Assembly panel (dropdown menu -> Starters -> Arduino).
Tinkercad circuit is also built in-
When drawing a drawing of serial data, the premise is that there is no text in the stream.
This is very convenient for visualizing changes in sensor readings and other inputs as well as tracking variables in the program.
Once the serial monitor is turned on, click the graphics button to open the graphics panel.
Remove the sensor tag block you added earlier, or create a serial data stream without text using the new Arduino serial launcher.
Start the simulation and interact with the input to observe the change of the graphic value.
You can choose to set up a physical circuit to handle this or digital input or analog input course and then use the Arduino Software of your computer to view the serial data entered via a USB cable.
To program your physical Arduino Uno, you will need to install the free software (
Or plug-in for web editor)
, Then open it.
Connect the Arduino Uno circuit by inserting components and wires to match the connection shown in the Tinkercad circuit. For a more in-depth walk-
By working with your physical Arduino Uno board, check out the free Arduino class (
Similar circuits are described in lesson 3).
Copy the code from the Tinkercad circuit code window and paste it into an empty sketch in the Arduino Software, or click the download button (
And open the result file using Arduino.
You can also find these examples in Arduino Software by navigating to files-> Examples -> 03. Analog -
> AnalogInOutSerial or file> Examples -> 02. Digital -
> Digitalinput pullup.
Plug in the USB cable and select the motherboard and port in the Tools menu of the software.
Upload the code to your motherboard and click the magnifying glass icon in the upper right corner to open the serial monitor.
Check carefully if the baud rate matches the baud rate in the settings.
Press the button or turn the knob to observe the digital change in the serial monitor window.
Now that you have learned to print to a serial monitor, you can test new digital and analog sensors and also learn to read incoming serial data (
User keyboard input.
Can you write a circuit and program to print the analog and digital inputs shown in this lesson?
Below is a link to the circuit and its Arduino code as shown in the figure: continue to try the new sensor and combine the input and output, for example in the temperature sensor LED bar chart course, PIR motion sensor course, or light resistance course. (coming soon).
Use the computer\'s keyboard to send serial data to Arduino and use S (
You can also learn more electronic skills through free guided courses such as Arduino, basic electronics, led and lighting, 3D printing, etc.