Bluetooth LED
What will we do
In this lesson we will learn how to switch an LED’s on and off from our Android phone using a bluetooth module.
We will wire up our circuit to include a LED and a Bluetooth module. We will also write some code that will read a character for the Android app that will tell the LED to come on and go off.
we will use character a to turn on the LED and character b to switch off the LED
The Android app can be downloaded here.
Please ensure that you have mBlock setup on you computer. Click here to setup mBlock
Parts List
You will need the following parts:
1x arduino uno
1x arduino USB Cable
1x Breadboard
7x Jumper Wire
1x LED (any colour)
1x Resistor
1x HC-05 Bluetooth module.
I purchased my module from this store.
Wiring it up
mBlock IDE
Launch the mBlock IDE (https://ide.mblock.cc/#/) and select the Arduino Uno Device and install the Kids Code Extension
Block Coding
You can find the green coding blocks under Bluetooth HC-05 at the bottom of your block list
Block Coding Explained
Using the green Start Bluetooth HC-05 block you initialize the Bluetooth
You need to check if the bluetooth is receiving data, using the green HC-05 receiving data block
If you receiving data then you will read the data from the Bluetooth using the read data from HC-05 block.
You will then check if your received character a and then turn ON the LED at pin D5.
You will also check if your received character b and then turn OFF the LED at pin D5.
Please remove the green RX jumper from the Arduino board before you upload your code. If the jumper is not removed then you will get an error.
Testing your code
Down the Android app from here.
Pair the bluetooth with your phone. Search for HC-05 and pair this device. The password will be 1234
Open the app and press the Connect button
Select HC-05 from the list.
Once connected, press the ON button and your LED should light up.
Press the OFF button and the LED will go OFF
Last updated