O'Reilly logo

Arduino Development Cookbook by Cornel Amariei

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling the Arduino over serial

In the Serial output recipe, we've seen how easy it is to print some data from Arduino to the computer. However, this can work the other way. In the serial monitor window in the Arduino IDE, we can write a string and send it to Arduino.

Here, you will learn what to do with that string and how you can use it to control things.

Getting ready

There is just one ingredient needed to implement this recipe—an Arduino board connected to a computer via USB.

How to do it…

Connect Arduino to the computer so that we can start programming it. The following code will start the built-in LED when it receives an 'a'. It will stop the LED when it receives an 'x', and will blink it for a specified amount of time when it receives

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required