The FORMAT command formats a disk with FAT and sectors. In most cases, this should only be used on floppy drives or other removable media. This command can erase everything on the storage device. A unique serial number will be created for storage device after formatting.
The two circuits in this lesson use the same configurations as the previous two lessons on digital input with a pushbutton and analog input with a potentiometer. The only differences are that these circuits are free-wired (no breadboard) and do not have an external LED wired up. Oh, and they are running code to generate serial messages, which we'll learn about in this lesson.
After duplicating the sample circuit into your 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 just before the serial block that's already in the program.
When the code editor is open in Tinkercad Circuits, you can click the dropdown menu on the left and select "Blocks + Text" to reveal the Arduino code generated by the code blocks (not available in the embedded module in the first step). This code sends data from the Arduino to the Serial Monitor, but in a later lesson you can also learn how to receive data from the Serial monitor and two way serial communication.
The code inside the loop reads the state of the input with digitalRead() and stores it in the buttonState variable. Then a function called Serial.println() sends the data to the monitor (over the USB cable in the case of a physical Arduino board). If you made the blocks changes to the program in the previous step, you will also have a Serial.print() line of code. println sends a new line after the message, and print does not. Use quotes around text labels, for instance Serial.print("sensor: ");. If you want to make a single line of serial debugging output, you may use several Serial.print() commands followed by a single Serial.println().
Tinkercad Circuits also has built-in graphing of your serial data, provided the stream doesn't have any text in it. This is handy for visualizing changes in sensor readings and other inputs, as well as for tracking variables in your program.
With the Serial monitor open, click the graph button to open the graph panel. Remove the sensor label block that you added earlier, or use a fresh Arduino serial starter to create a serial data stream with no text.
You have the option to build a physical circuit to go along with this or the digital input or analog input lessons, then use your computer's Arduino software to view the serial data coming in over the USB cable. To program your physical Arduino Uno, you'll need to install the free software (or plugin for the web editor), then open it up.
Upload the code to your board, then click the magnifying glass icon in the upper right corner to open the serial monitor. Double check that the baud rate matches the one in your setup Serial.begin(9600).
Continue on to try a new sensor and combine inputs and outputs, for instance in the temperature sensor LED bar graph lesson, PIR motion sensor lesson, or photoresistor lesson. (coming soon).Use your computer's keyboard to send serial data to your Arduino and interpret it with Serial.read() (lesson coming soon). 2b1af7f3a8