Hello and welcome back, everyone!
In the previous video,
we learned how to interface a "servo motor to Arduino Uno using PictoBlox"
and wrote a script to control it using an "IR sensor".
In today's video,
we’re going to write a script to "OPEN" and "CLOSE" a door
by controlling a servo with a Smartphone via "Dabble",
a "project-making" application that transforms
your Smartphone into "virtual Arduino shields".
Let’s begin!
First, open "PictoBlox".
Then, connect Uno to your computer via a USB cable.
Next, click on the "Board" button in the toolbar
and select its name from the "drop-down menu".
Then, click on the "Connect" button and select the appropriate "port".
Now, let’s connect the "Bluetooth module 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 "GND(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".
Connect the servo’s "brown wire" to Uno’s "GND (ground) pin"
using a black male-to-male jumper cable.
Next, connect the "red wire" to Uno’s "VIN pin"
using a red male-to-male jumper cable.
Then, connect the "orange wire" to Uno’s "PWM pin 5"
using a yellow male-to-male jumper cable.
And we’re done.
Now, let’s write the script to control the servo.
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 on () to () angle 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.
Now comes the fun part:
pairing "Dabble with Uno".
Install Dabble from "Play Store"
and open it on 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.
Now, open the "Terminal module" and you’re ready to go!
We hope that you had as much fun as we did
making these tutorials for you!
If you have any questions regarding this video,
let us know in the comment section below.
And if you liked the video,
don’t forget to give it a thumbs up (and SUBSCRIBE for more educational videos like this)!
We’ll meet again sometime.
Till then, happy tinkering!
