0Pricing
Arduino & IoT Academy · Lesson

Read Commands You Type

Use Serial input to trigger actions from your keyboard.

Read Commands You Type is a free Arduino & IoT Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Talk Back to Your Board

Serial works both ways. You can type into the Monitor and your board will read it, letting you send commands from your keyboard. ⌨️

Is Anything Waiting?

First check if data has arrived with Serial.available(). It returns how many bytes are sitting in the buffer, ready to read.

if (Serial.available() > 0) {
}

Why Check First

Reading when nothing is there gives junk. So you guard your read with available() and only act when real data exists.

Read One Character

Grab a single incoming character with Serial.read(). It pulls one byte from the buffer and hands it to you.

char c = Serial.read();

React to a Command

Now branch on what you got. Compare the character and run different actions, like turning an LED on or off.

if (c == '1') digitalWrite(13, HIGH);
if (c == '0') digitalWrite(13, LOW);

Mind the Quotes

Notice the single quotes around '1'. That is a character, not the number one, and matching it correctly matters.

Reading Whole Words

For full commands like on or off, read a whole line with readStringUntil(), stopping at the newline you send.

String cmd = Serial.readStringUntil('\n');

Compare the Text

Then test the whole word. If the String equals on, do one thing; if it equals off, do another.

if (cmd == "on") digitalWrite(13, HIGH);

Set the Line Ending

In the Monitor, pick a line ending like Newline. It tells readStringUntil where each typed command stops.

Confirm Back

Good feedback feels great. After acting on a command, println a confirmation so you know the board heard you.

Serial.println("LED is on");

Now It Is Interactive

You just built a tiny command interface. Type, the board reads, acts, and replies. That is real two-way control. 🚀

Quick Check

Which function tells you whether typed data has arrived and is waiting to be read?

Recap

You made the board listen: checking available(), reading characters or full lines, acting on commands, and confirming back. Two-way Serial done! 🎉

Frequently asked questions

Is the “Read Commands You Type” lesson free?

Yes — the full text of “Read Commands You Type” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.

What will I learn in “Read Commands You Type”?

Use Serial input to trigger actions from your keyboard. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Arduino & IoT Academy?

No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Read Commands You Type” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Arduino & IoT Academy lesson?

Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Serial.begin and Baud Rate
  2. Serial.print vs println
  3. Watch Sensor Values Live
  4. Read Commands You Type
← Back to Arduino & IoT Academy