Projects / Serial debug console

Serial debug console

Beginner30 minGuided buildReviewed
Arduino UnoD9A0GNDLED D9> led onok led onSerial monitor
Serial at 115200 baud

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. UNO14.2 mA

    LED

    D9 through 220 Ω.

  2. UNO

    Pot

    Wiper to A0.

  3. UNO

    Upload

    Open the serial monitor at 115200 with Newline.

  4. UNO14.3 mA

    Try commands

    led on, pwm 40, read a0, status.

In short

How do you build a serial debug console?

Type commands like "led on", "read a0" or "status" into the serial monitor and the Arduino answers: a habit that makes every later project easier to debug. You need Arduino Uno R3, LED 5 mm red, Resistor 220 Ω, Potentiometer 10 kΩ and Breadboard 830 Tie Points. It takes 4 steps and about 30 minutes.

Level
Beginner
Time
About 30 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
D9 → 220 Ω → LED → GNDSomething to switch
Pot wiperA0 (ends to 5V and GND)Something to read

Code

No libraries. Set the serial monitor (or the Workshop serial monitor) to 115200 baud and Newline line ending.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

String line;

void help() { Serial.println("Commands: led on | led off | pwm <0-255> | read a0 | status | help"); }

void run(String c) {
  c.trim(); c.toLowerCase();
  if (c == "led on") { digitalWrite(9, HIGH); Serial.println("ok led on"); }
  else if (c == "led off") { digitalWrite(9, LOW); Serial.println("ok led off"); }
  else if (c.startsWith("pwm ")) { int v = constrain(c.substring(4).toInt(), 0, 255); analogWrite(9, v); Serial.print("ok pwm "); Serial.println(v); }
  else if (c == "read a0") { Serial.print("a0 = "); Serial.println(analogRead(A0)); }
  else if (c == "status") { Serial.print("uptime "); Serial.print(millis() / 1000); Serial.print(" s, a0 "); Serial.println(analogRead(A0)); }
  else if (c == "help" || c == "") help();
  else { Serial.print("unknown: "); Serial.println(c); }
}

void setup() { Serial.begin(115200); pinMode(9, OUTPUT); help(); }

void loop() {
  while (Serial.available()) {
    char ch = Serial.read();
    if (ch == '\n') { run(line); line = ""; } else if (ch != '\r' && line.length() < 40) line += ch;
  }
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

Commands: led on | led off | pwm <0-255> | read a0 | status | help

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
helpLists the commands
pwm 40LED dim, reply "ok pwm 40"
Nonsense"unknown: ..." and nothing breaks

If it does not work

No reply

Line ending set to No line ending: choose Newline.

Garbage text

Baud rate mismatch: both must be 115200.

Commands ignored when typed fast

Lines over 40 characters are cut; keep them short.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the serial debug console?

Arduino Uno R3, LED 5 mm red, Resistor 220 Ω, Potentiometer 10 kΩ and Breadboard 830 Tie Points.

How long does the serial debug console take to build?

About 30 minutes for a beginner maker, in 4 steps.

How do I know the serial debug console works?

help: Lists the commands. pwm 40: LED dim, reply "ok pwm 40". Nonsense: "unknown: ..." and nothing breaks.

No reply: what should I check?

Line ending set to No line ending: choose Newline.

Garbage text: what should I check?

Baud rate mismatch: both must be 115200.

Commands ignored when typed fast: what should I check?

Lines over 40 characters are cut; keep them short.