O'Reilly logo

Mastering Arduino by Jon Hoffman

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

Project 2 – controlling LED

In this project, we will turn an LED that is connected to the Arduino on or off depending on the input from the phone. The first thing we will need to do is to add the LED to our circuit. The following diagram shows the new circuit:

The LED is connected to the digital 5 pin on the Arduino through a 330-ohm resistor. Now we need to write the code to control the LED. We will start by setting up the SoftwareSerial library for the Bluetooth module and defining the pin that the LED is connected to. The following code will do this:

#include <SoftwareSerial.h>
#define LED_PIN 5
SoftwareSerial HM10(10, 11);

We can see that ...

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