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 the Bluetooth module is connected to the same pins as the previous example, and the LED is connected to digital pin 5 on the Arduino. In the setup() function, we will need to configure the SoftwareSerial instance and the...