Once you are there on the bed or sofa, you hate to get up to open the door. Well, this tutorial is the perfect solution. By the end of this tutorial, you will be able to open/close the door or any ON/OFF any motor by just typing a few words on your Smartphone. All of this is possible because of Dabble: a project-making app, that transforms your Smartphone into many virtual shields.
In this tutorial, we are going to interface a servo motor to Arduino Uno and control it wirelessly using Smartphone via Bluetooth Module. Also, the entire process just got easy as you are going to code the entire program in PictoBlox, a graphical programming software which eliminates the need to worry about syntax.
Interfacing the Bluetooth Module and the Servo
- Let’s connect the Bluetooth module(HC05) to Uno. It will help us pair our Smartphone with the board via Bluetooth.
- Connect the VCC pin to Uno’s 5V pin using a red male-to-female jumper cable.
- Next, connect the ground pin to Uno’s ground pin using a black male-to-female jumper cable.
- Now, connect the transmit pin (Tx) to Uno’s digital pin 2 using a green male-to-female jumper cable.
- Then, connect the receive pin to Uno’s PWM pin 3 using a blue male-to-female jumper wire.
- Now, let’s connect the servo to Uno.
- Connecting Uno to the computer.
Activity: Control Servo with a Smartphone via Dabble
Writing the Code:
Now, let’s write the script to control the servo in PictoBlox.
- Click on the Dabble palette. You’ll see that it has blocks for all the different modules of the app such as LED control, Terminal, Gamepad, Motor Control, etc. We’re going to give textual commands using the Terminal module to control the door.
- First, let’s work on closing the door. It should close if the command given is ‘close’. So, drag and drop an if block into the scripting area.
- Then, drag and drop the is data from terminal block into the hexagonal space of the if block and write close in the white space.
- Next, drag and drop the set servo block and set the angle to zero degrees.
- Now, to open the door, we must send the command ‘open’.
- Duplicate the entire set of blocks and stack the two.
- Now, write open in the white space of the second is data from terminal block and change the servo angle to 45 degrees.
- Add a forever block to the script from the Control palette.
- Drag and drop the set bluetooth baud rate to block above the forever block and set the baud rate to 9600.
- Finally, drag and drop the hat block. Our script is now complete!
- Upload it to Uno by switching to the Upload mode and clicking on the Upload Code button.
Pairing Dabble with Uno
- Install Dabble from Play Store and open it in your Smartphone.
- Next, click on the connect-disconnect icon.
- A dialogue box will appear on the screen asking for permission to turn on Bluetooth. Click on ‘Allow’.
- Once you do so, a list of nearby devices will appear. Select your device’s name.
- In case you don’t see it on the list, go to the Bluetooth settings of your Smartphone and search for it there.
- If your Smartphone asks for a password to pair it with the device, enter the default password. For HC-05 and HC-06, it is 0000 or 1234. For HM-10 it is 000000 or 123456.
- A notification will appear in the drop-down menu of the phone once the connection is made.
- Now, open the Terminal module and you’re ready to go!
Let’s try implementing this tutorial in the miniature house that we have made. Connect the Bluetooth module of the house to Dabble. Once done, open Terminal Module and type the command. Don’t even want to type the commands, voice commands are here to save your day!
You can try controlling the other components like lights of your house.
In this tutorial, we learned how to control actuators or send commands to them wirelessly via a Smartphone using Dabble.
Hope you had fun! Happy tinkering! 🙂