We are all guilty of sleeping with our smartphones within our arm’s reach every night. The first thing we do in the morning is checking it for social media updates and online store offers. It has often made us wonder if that is all our mobile phones are good for. Is it just another fancy alarm? Is it another way for us to abate our social media addictions? It turns out, our smartphones can be a lot more than that. With a little effort, we can control electronic devices with it.
It is undoubtedly cool to be able to control other devices with android phones, but learning the process takes time. So the trick is to take baby-steps towards perfecting our coding skills and circuit building skills. This tutorial will present a way of creating a LED control interface on your phone via Arduino and Bluetooth modules. You can also check out some online Arduino tutorials to get a good grip in this area.
For this project, you might want to update your Arduino board to a UNO that has 13 digital pins and 7 analog pins. Using it will give you several connection options that can help you build the circuit successfully within a couple of minutes.
Yes! That’s indeed all the time you need to be able to control LEDs with your smartphone using Arduino boards.
Here’s what you will need to build a cost-effective circuit for controlling LEDs
- Arduino UNO or Arduino NANO
- A LED strip or standard LED lights
- Bluetooth HC-05 module
- Resistor 1K and 2K
- Jumper wires
- 9V battery and cap or use your USB cable
Step 1: Building the circuit
Any Arduino project has two critical components – building the hardware and developing the software. Advanced users have probably built similar circuits before so that they can play around a little bit with the parts. In case, you are doing this for the first time – you can follow the next schematic to build a complete circuit.
Step 2: HC-05 Bluetooth module
You should connect the Bluetooth module to the Arduino board via the male-to-female jumper wires. Make use of the Vcc, GND, Tx and Rx pins to establish connections, but leave out the State and En pins. You shall find the necessary connections in the circuit diagram.
For a Logic Level 3V Bluetooth module, do not connect the Arduino board to the module directly. You should use the pull-down resistor at each pin to create a voltage divider.
Step 3: Preparing the RGB LED strip
Depending on the type of LED you pick, the connection will vary. There are two common types of RGB LED strips – Anode and Cathode. This project has used the common anode type, and the micro-controller program depends on that. Connect the anode of the LED via a PWM pin. Always be careful enough to mention the correct pin number for initialization of the connection.
NOTE: proper LED strips tend to burn a hole in the pockets. In case you cannot afford one, do not worry! Get the cheaper 3V standard LED lights and solder the cathodes/anodes together to create common Cathode or common Anode type LEDs.
You can use the following code snippet to initialize the connection.
Step 4: Programming the microcontroller
The sketch to the controller varies depending on which Arduino version you use as a controller. However, it has only one purpose – it receives the smartphone signals via Bluetooth. According to the signal, the IDE uses the Pulse Width Modulation (PWM) to vary the resistance to ground for the common anode LEDs. In case of common cathode LED strips, the potential to the ground is changed as per the signal.
The code snippet above contains the complete Arduino sketch you need to control the LED strips. If you are a pro Arduino user, you can draw your own program and experiment with the variables.
NOTE: understanding the code
When we upload the code snippet to Arduino, the board understands it and accordingly switches the LEDs on and off. When the Bluetooth module sends across the binary digit “1” to the LED is switched on. When the LED receives the binary “0” the light switches off. Therefore, when you send a message via the Bluetooth Module that has the “1”, the LED strip switches on.
Step 5: downloading and using the Android Application
To assume absolute control on the LED strips, you might want to download a ready-to-use, open-source application compatible with your Android smartphone. You can download Bluetooth terminal applications via Google PlayStore. Check the reviews of the application before you sit down to use it. The user interface will determine a significant part of your experience. So go with something that is straightforward and easy on your phone.
After the installation is complete, turn the Bluetooth of your Android phone on and pair the HC-05 module with it (Its default passcode is 1234). Ensure that the Arduino board is connected to a power source as per the given circuit diagram.
Step 6: TEST IT
No project is complete without adequate tests and dry runs. Once your connection is complete, test it out with the color disc on your phone. The different saturation value of the RGB determines the different colors of the LED.
Controlling LEDs with smartphones is a simple project that requires basic components. It is ideal for pro Arduino users, as well as beginners, who are just exploring the endless potential of using Arduino. The circuit has 3 crucial components – the android device, Bluetooth module and the Arduino board. The code involved in the project and its modifications will act as a signifier of your expertise.