How to Control DC Motor With Android Smartphone, Arduino and Bluetooth With RemoteXY Application
Try Code Monkey: Coding for Kids
How does it work?
Smartphone Interface
You can use the free RemoteXY editor from the website RemoteXY.com to design a stylish smartphone interface that can control your Arduino circuit. With all the switches, pushbuttons and sliders that make your application work smoothly.
You may also like this post about ESP8266
We’ll see how you can choose the core details of your Arduino circuit and communication method.
Arduino Sketch and code
Then finally, the RemoteXY Editor automatically generates the Arduino code for you.
Then all you need to do is to upload the sketch to your Arduino board and then run the RemoteXY app on your smartphone and get started.
You don’t have to connect to internet to connect your smartphone and Arduino circuit with Bluetooth.
RemoteXY Editor generates Arduino sketch with all needed code and also data of the interface such as buttons and sliders.
The RemoteXY library seamlessly sends the interface and configurations data from Arduino board to your smartphone RemoteXY app and then the Smartphone App interprets the interface offline without the need to connect to internet.
Supplies:
Arduino Pro Mini Board Amazon UK , Amazon DE , Banggood
Here, I used Arduino Pro Mini to make the circuit smaller to use in other applications
However, You can use any Arduino board and you can choose it from the RemoteXY editor as we’ll see.
USB to TTL converter Amazon UK , Amazon DE , Banggood
Since Arduino Pro Mini has no USB port, you need this program Arduino Pro Mini from your computer.
Bluetooth Module HC-06 Amazon UK , Amazon DE , Banggood
2N2222 NPN transistor
We’ll use this transistor as a switch to control the DC motor with Arduino.
3 volt DC Motor Amazon UK , Amazon DE , Banggood
3.7 V battery Amazon UK , Amazon DE , Banggood
Some wires
Step 1: RemoteXY Editor
Open RemoteXY.com, create a new account if you don’t have one and Login.
Create a new project and name it.
First, from configuration tab on the right, choose
Connection — Bluetooth
Device – Arduino Pro Mini
Module – HC-06
IDE — Arduino IDE
Open Module interface tab on the right, choose
Connection interface —- Software Serial
RX Pin —- Pin 7
TX Pin —- Pin 8
Baud Rate 9600
Design the Smartphone interface
From the left toolbox choose
ON/OFF Switch and place it on the blank phone screen
Slider and place it on the phone screen
From the right side choose the element tab choose Switch
Snap to PIN —- PIN 6
You can also choose to change switch caption ON/OFF and color from here.
From the right side choose the element tab choose Slider
Orientation — Horizontal
From the View tab on the left side choose Background color.
Place the controls on the place you want to become final and resize them.
Save the project.
Step 2: Get Arduino Code
Click the Green button on the right side Get Source Code
You get the generated Arduino code on the screen.
You can see the Arduino code on the screen and you can either choose to select and copy it or you can click Download Code
Click Download Library to get the RemoteXY.h library
Download RemoteXY App from App Store if you have iPhone or from Google Play Store if you have an Android Smartphone.
Step 3: Arduino IDE and Upload Code
Open Arduino IDE and paste the code you copied into a new
sketch or open the downloaded code.
That’s all the code we need to control the motor ON and OFF from the smartphone with Arduino and Bluetooth circuit.
The ON/OFF switch is connected to PIN 6 which controls the NPN transistor which runs as a switch to deliver power to the DC motor.
To use the slider as a speed control we need to connect it to PIN 6 that controls the NPN transistor.
The speed control is done with PWM Pulse Width Modulation function (Known As Analog Write in Arduino)
We need to add two lines of code to connect the RemoteXY slider to PIN 6. We add them to the loop function.
Here they are
int MotorSpeed = RemoteXY.slider_1 * 2.5 ;
analogWrite(6, MotorSpeed);
In the first line of code, we define the MotorSpeed variable we read from the slider inside the RemoteXY interface.
The slider in the interface reads values from 0 to 100. So we need to scale that value to be compatible with the analogWrite() function in Arduino. The analogWrite() function outputs values from 0 to 255 which outputs 0 to 5 volts according to the value between the parenthesis ().
That’s why we need to scale it by multiplying it to 2.5.
In the second line of code we output the MotorSpeed directly to PIN 6 connected to the NPN transistor and the DC Motor.
Here is how the loop function looks like.
Save the code and Compile it to check that it’s correct with no errors.
Attachments
Step 4: Assemble Arduino Circuit
Connect the circuit as in the images.
Here is another post that describes how to program Arduino Pro Mini in more details.
First, we need to connect Arduino to USB-to-Serial Converter to program the software. Normally, you don’t need this step if you use Arduino UNO or any other Arduino board that has a built in USB port.
USB-to-Serial ———– Arduino Mini
3.3 v ———————– VCC
GND ———————- BLK
RXD ———————- TXD
TXD ———————- RXD
DTR ———————- GRN
Caution:
Make sure that you power Arduino Pro Mini with 3.3 V
Upload the sketch to Arduino Pro Mini
Then we connect the final circuit to Bluetooth module and the motor
HC-06 ——————– Arduino Pro Mini
VCC ——————– VCC
GND ——————– GND
RXD ——————– PIN 8
TXD ——————– PIN 7
Connect the 2N2222 NPN transistor to Arduino Pro Mini
Collector ——————- Motor Power Supply
Base ——————– PIN 6
Emitter ——————– GND
Step 5: Run the Final Project
Connect the circuit to the battery and power the circuit.
Run the smartphone RemoteXY application.
Connect Bluetooth and start controlling the motor ON/OFF and the motor speed with the Slider.
Recent posts
- My Six Years Old Son Wanted to Build His own Flying CarBuilding My Son’s Dream: A Flying Car with Tinkercad and Arduino Ever since my 6-year-old son could talk, he’s been fascinated by the idea of flying cars. He would sketch designs, build models with his toys, and talk about how one day he would soar above the ground in a car with wings. His dream… Read more: My Six Years Old Son Wanted to Build His own Flying Car
- How I made My Kids #Arduino #Flying Car #Tinkercad Dream #Aviation #AeroArduinoIntroduction: Welcome to a new project from AeroArduino, where we turn dreams into reality! In this exciting project, we’re bringing to life a childhood dream of creating an Arduino flying car using TinkerCAD. If you haven’t subscribed yet, be sure to hit that subscribe button to stay updated with our latest projects. Circuit Connection: Let’s… Read more: How I made My Kids #Arduino #Flying Car #Tinkercad Dream #Aviation #AeroArduino
- Easy #Tinkercad #Arduino distance measurement using ultrasonic sensor #AeroArduino
- Building a Smart Ultrasonic Car With Code Blocks on TinkercadToday, I want to share an exciting project that brings together ultrasonic sensors, motors, and a sprinkle of programming magic to create a Smart Ultrasonic Car. Imagine a little robotic vehicle that can sense its surroundings and make decisions on the fly – that’s exactly what we’re diving into! The Heart of the Project: Ultrasonic… Read more: Building a Smart Ultrasonic Car With Code Blocks on Tinkercad
- Super Simulation for Accelerometer with Arduino in TinkercadIntroduction The world of electronics education often relies on simulation software to bridge theoretical knowledge and practical application. TinkerCAD stands as a prominent platform for simulating electronic components, aiding enthusiasts and learners in experimenting virtually. In this tutorial, we’ll explore how to overcome the absence of an accelerometer component in TinkerCAD by using a creative… Read more: Super Simulation for Accelerometer with Arduino in Tinkercad
- Monitoring Soil Moisture with Arduino and LCD: A Step-by-Step GuideHow to Build Step-by-Step Arduino Soil Moisture Sensor With Tinkercad Simulation – DIY Guide on AeroArduino
- Revolutionizing Aircraft Ground Handling: The Advantages of Remotely Controlled TugsIntroduction: The aviation industry has witnessed minimal innovation in aircraft tugs, resulting in outdated and inefficient ground handling operations. However, the advent of remotely controlled aircraft tugs has the potential to transform ground handling practices. These advanced tugs offer numerous advantages over traditional counterparts, including increased efficiency, improved safety, and reduced environmental impact. In this… Read more: Revolutionizing Aircraft Ground Handling: The Advantages of Remotely Controlled Tugs
- The Mighty Antonov AN-22: Revolutionizing Cargo Transportation in the SkiesIntroduction: In the realm of aviation, where technological advancements continually push boundaries, the Antonov AN-22 shines as a true marvel. With its massive size and unparalleled cargo-carrying capabilities, this iconic propeller aircraft has carved its name in the annals of aviation history. Join us as we delve into the world of the Antonov AN-22 and… Read more: The Mighty Antonov AN-22: Revolutionizing Cargo Transportation in the Skies