Serial.print: see your knob's number

// WHAT YOU WILL LEARN

Serial.begin + Serial.println(knob) prints the analogRead value to the Serial Monitor on your laptop.

// LESSON NOTES

Your knob is connected… but what number is the Arduino really reading? 🎛️👀

1️⃣ OPEN A LINE: in setup() write Serial.begin(9600); — it opens a line to your laptop over the USB cable at 9600 bits per second.

2️⃣ PRINT IT: in loop() read the knob and print it:
int knob = analogRead(A0);
Serial.println(knob);
delay(100);
Open Tools → Serial Monitor and you see 0 to 1023, live, as you turn the knob.

3️⃣ GARBAGE ON SCREEN? The Serial Monitor must use the SAME speed as your code. Set it to 9600 baud too and the numbers appear.

📌 Can't see what your code is doing? Print it!

CODE FROM THIS LESSON
int knob = analogRead(A0);
Serial.println(knob);
delay(100);
Read the voiceover (transcript)
  1. What number is your knob really reading?
  2. In setup: Serial dot begin, ninety-six hundred. A line to your laptop!
  3. In loop, print the knob. The Serial Monitor shows zero to ten twenty-three, live!
  4. Seeing garbage? Set the monitor to ninety-six hundred too!
  5. Can't see it? Print it!
  6. Next: millis versus delay! Follow for part twelve!

Related lessons