ARDUINO PHONE-CONTROLLED ROBOT ARM
The robot arm includes 5 degrees of freedom and can be controlled by a phone via Bluetooth.
Area of Interest
Biomedical Engineer / Computer Engineer
Galileo Academy of Science and Technology
Fourth Milestone / Demo Night:
Mounting the Robot Arm Onto the Chassis and Driving the Car
Here is a front view of the robot arm mounted on top of the chassis.
Here is an image of the app I developed to control my robot arm and its movement.
For this step of my project, my goal is to build a code that allows the car to move according to the directions it receives from a Bluetooth device, and then to attach the robot arm onto the chassis to enable movement. This is what I presented during my Bluestamp Demo Night.
A new component I added onto my project is the Ultrasonic Sensor (the HC-SR04 Ultrasonic Sensor), a sensor that measures the distance of a certain object from itself by constantly sending out and receiving sound waves. The sensor has two main parts: the transmitter and the receiver. The transmitter sends out the sound waves at ultrasonic (faster the the speed of sound, which is 1225 km/h at sea level on Earth); once it hits an object, it bounces back. The receiver detects the sound wave that is bounced back, and the sensor then measures the time it took for the sound wave to be transmitted by the transmitter and then received back by the receiver. According to the time, it can then calculate the distance between the sensor and the object.
To control the robot arm and its movement, I need to build and use an app on my Android device (which serves as my Bluetooth controller). For this step, I used the MIT App Inventor 2. Building off the app I used to control my four servo motors (as described in Milestone Two), I added a new section underneath that allows me to drive the car. The nine black buttons above the “Autodrive” button are used to drive the car manually, while “Autodrive” allows the car to move by itself autonomously (as described in the following section). I also made a few changes to the color and the layout of the app to make it more colorful and appealing.
Here is the Arduino code that I built to control the car in two modes. In mode one, the car drives according to the Bluetooth signals it receives from a Bluetooth device. In mode two, the car drives autonomously. It will keep moving forward until it detects (using the Ultrasonic Sensor) an object within 10 inches in front of it; then it will automatically stop, move backward, and turn left to avoid the object. Once the object is avoided, it will continue to move forward.
How does the Arduino understand your command based on the buttons you click on the app? On App Inventor, I coded each action button on the screen to send a certain numerical value of Bluetooth Serial signal. Then, on Arduino, I would add the appropriate action(s) that corresponds with each numerical value. For example, when the button “Forward” is clicked, the phone sends a Bluetooth Serial value of 600. On Arduino, I coded that when a Serial value of 600 is received, the DC motors would turn forward. Thus, when the button “forward” is clicked on the app, the robot arm moves forward.
I faced several challenges and learned a lot of new things during this milestone.
Firstly, when I tried to integrate the serial-reading feature as the means to understanding the commands from the app on the Bluetooth device, I had to constantly check the Serial Monitor on Arduino to make sure that the right signals are sending through when certain buttons are clicked. When the Serial value does not correspond with the button being clicked, I have to debug. This process, though difficult, helped me to utilize the Serial Monitor as a tool that makes debugging a lot easier.
Secondly, I also had to set up a system of conditions to monitor the activity of the Ultrasonic Sensor. This process was especially difficult as I do not have a lot of space in my working area, so it was difficult to discern whether or not the Ultrasonic Sensor was sending back the right distance on the Serial Monitor. However, this allowed me to learn how to employ logic statements like “if and only if” on Arduino, and by the end of this process, I became more trained in wielding these logic statements.
Thirdly, I had a lot of trouble wiring all the wires from the Robot Arm, Ultrasonic Sensor, the Chassis, and the Bluetooth Breakout Board. This was made harder when I switched from using a regular-sized breadboard to a Mini Breadboard. It took a lot of time and patience to condense the wiring strategically and still make sure all the wires are in their proper place.
Lastly, I spent a lot of time mounting the Robot Arm unto the Chassis. The Chassis was not designed to hold something as huge as my Robot Arm, not to mention that I am also adding unto it a battery pack, an Arduino Uno Board, a Mini Breadboard, and a Power Bank. It took a lot of tries and hot glue, but ultimately, I was able to combine all the pieces of my project into one big robot!
Here is a side view of the robot arm mounted onto the chassis.
An image of my first attempt to mount the robot arm onto the chassis.
Assembling the Car Chassis and Testing the DC Motors
Here is a picture of the assembled chassis, connected to the Arduino Uno Board. All the wires from the robot arm and the chassis are connected to the Arduino through a Mini Breadboard.
For my first modification, I assembled a car chassis which I will later attach onto the robot arm to enable movement of the arm. Next, I tested to make sure that the DC motors on the chassis are fully functional.
To assemble the chassis, I followed this YouTube tutorial video, as well as the instruction manual that came with the chassis kit. Each DC motor on the chassis can be connected to two wires (which power the motors), and I wired the motors onto a motor driver (the L298N motor driver). Next, I wired the motor driver to the Arduino Uno Board, which requires 6 output pins, a 12V pin, and a GND pin. The motor driver is the power source that runs and directs the DC motors, according to directions sent from the Arduino Uno Board.
Here is the Arduino code that I used to test to see if the DC motors are functioning properly. The code can be found on this tutorial.
One valuable engineering skill that I learned during this step of my project was soldering. With a brand new soldering kit and a few practice runs with jumper wires, I was able to solder wires onto my DC motors to permanently attach them onto the motor driver. This skill proved to be useful as I discover that I need to solder more things in the next steps of my project.
After running the code and confirming that the DC motors and the motor driver are fully functional, I have completed the third milestone of my project. For my next step, I plan to write a code that would allow me to fully control the movement of the car in different directions. Additionally, I will also attach the car chassis onto the robot arm, so that the car can drive around.
Controlling the Robot Arm via a Basic Bluetooth Function
Here is a schematic of how my Bluetooth Module was set up:
Here is a picture of my actual wiring:
For my second milestone, I wired the four servo motors on my robot arm frame onto the breadboard to connect them to the Arduino Uno Board. Additionally, I also successfully connected a Bluetooth Breakbout Board (the ZS-040 Bluetooth Breakout Board) to the Arduino Board. These two steps allows for me to control the movement of the servo motors (and thus the movement of the robot arm) via a Bluetooth device, such as an Android smartphone.
To control the servo motors on my robot arm, I wire them up onto the Arduino Uno Board through a regular-sized breadboard. Each servo motor must be connected to the Arduino Uno Board through three pins: the GROUND pin, the 5V pin, and one of the digital pins (PWM) for signal. I also wired the Bluetooth Breakout Board; there are 4 pins on the Breakout Board that needs to be wired: the Ground pin, the 5V pin, the TX pin, and the RX pin.
Next, I need to test the movement of my robot arm by using an app and an Arduino code that can control the servo motors. I looked up several apps and Arduino code online, and finally I decided to settle with a simple Bluetooth app that allows for control of 4 servo motors. The YouTube tutorial includes the links to the app (created in MIT App Inventor 2) and the corresponding Arduino code.
Here is the Arduino code that controls the movement of the arm.
One huge and frustrating difficulty I encountered during this step was that two of the servo motors struggled to move due to low power source from the Arduino, and over-tightening of the screws. To mitigate this problem, I loosened the screws attached to those motors, added an external power source to add more power to the Arduino Uno Board, and added a few rubber bands to help the movement of the problematic joints.
As this milestone marks the conclusion of my base project, for my next step, I will add the first modification onto my robot arm: adding a chassis so that the robot arm can move around.
Assembling the Frame of the Robot Arm
Here is the concept of the finished frame according to the tutorial:
Here is a side view of the finished frame, with the Arduino Uno Board attached:
For my first milestone, I assembled the basic frame of the robot arm. The frame is consists of 4 servo motors, which allows for four degrees of freedom (or the movement of 4 joints). I have also attached the Arduino Uno board (a micro-controller that will serve as the brain of the robot arm) that unto the frame. To assemble the frame, I followed this Youtube tutorial video that I found online.
For the next step of my project, I aim to be able to control the robot arm from a Bluetooth device. To accomplish this, I will need to wire up the servo motors and a Bluetooth chip onto the Arduino Uno Board.