Today I explored how the Serial Monitor works in Arduino and how variables help store data. It was my first hands-on session, and I began understanding how communication between the Arduino and the computer happens.
Serial.begin()
to start serial communicationSerial.print()
and Serial.println()
Serial.begin(9600)
– Starts the Serial Monitor with a specific baud rateSerial.print()
– Prints a message or variable to the Serial Monitor (same line)Serial.println()
– Prints a message or variable and moves to a new lineint
– Integerschar
– Charactersfloat
– Decimal numbersbool
– Boolean values (true/false)I had a minor issue understanding the difference between Serial.print()
and
Serial.println()
, but testing them helped me see how the cursor moves with each.
void setup() {
Serial.begin(9600); // start serial communication
int myNumber = 5;
Serial.print("My number is: ");
Serial.println(myNumber);
}
void loop() {
// nothing here for now
}
It was a good start to understanding how data moves between the Arduino and computer. I’m excited to try input devices like buttons or sensors next.