Raspberry Pi Pico robot

Rather than use a standard controller, this robot is steered using an Android phone’s accelerometer. In the latest issue of The MagPi, David Crookes took a look.

Robotics projects have long been popular among the Raspberry Pi community, but MohammadReza Sharifi’s outstanding contribution definitely has a touch of va va voom about it. Powered by a Raspberry Pi Pico, his four-wheel drive car is controlled using the accelerometer in an Android smartphone. “The idea suddenly came to my mind,” he tells us, “and it took me about three hours to build and program.”

That itself is impressive, particularly given the work needed to get things moving. It all began two months ago when MohammadReza was browsing Instagram. “I saw a promotional video about a toy in which a coloured ball was being controlled by mobile gestures,” he says. “I thought to myself that controlling a robot using mobile gestures could also be an interesting project.”

From that point on, he quickly looked to gather the equipment needed. To start with, he bought an inexpensive plastic robot car chassis kit which came complete with four yellow wheels and four DC gear motors. He then added a L298 motor driver and an HC05 Bluetooth module. 

Raspberry Pi Pico Robot
Raspberry Pi Pico processes the movement data in real-time, and sends the information to the motor driver

Speeding ahead

“I decided to connect these to a Raspberry Pi Pico microcontroller,” he says. “I’d seen that a small number of robotics projects had been implemented using Raspberry Pi Pico, and I wanted to experience the challenge of working with the microcontroller.”

To ensure that the robot could make use of a smartphone’s accelerometer, MohammadReza needed to develop a custom app. He did so using the MIT App Inventor platform (appinventor.mit.edu) – a blocks-based visual programming environment that makes it relatively easy to create software for mobiles.

“The main advantage of this platform is that you don’t have to deal with coding challenges because it lets you focus more on the main concept of a project,” MohammadReza explains. That said, it wasn’t totally straightforward, as you can perhaps imagine.

Raspberry Pi Pico Robot
The smartphone’s accelerometer not only picks up left and right movement, but allows MohammadReza to tilt forward and back to control the direction

Twists and turns

The idea was to create an app that would send data from the accelerometer to Raspberry Pi Pico in real-time via a Bluetooth connection. That way, MohammadReza could tilt his smartphone left, for instance, and send information telling the robot to move left. 

This is what took up much of the development time. “The biggest challenge was definitely building the mobile app,” he reveals. “It needed to identify the co-ordinate axes and identify the position of the accelerometer sensor in the mobile. It also needed to perform trial and error to find the amount of angular acceleration and the magnitude of acceleration.” 

Raspberry Pi Pico Robot
The project cost about £40 to make

Eventually, however, it began to work near-flawlessly. He’s now considering creating a version for iPhone, but although the MIT App Inventor web application is free, open-source, and allows apps to be made for iOS and Android, he’s decided to use a different system for the Apple device. 

“I will create an iOS app for the robot using Kivy,” he says, referring to the free and open-source Python framework and relishing a fresh challenge. His priority first and foremost this time around, he adds, was just getting it to work with his Xiaomi Redmi Note 9 Pro Android smartphone and he’s more than happy to see it going down well with other makers online. “It makes me proud that people are interested in my project,” he beams.

2 comments
Jump to the comment form

Avatar

F1 or R1

Reply to Supra

Avatar

Very nice! Once I am allowed to do group projects outside of school again, this will be a great project to try.
Thank you.

Reply to Jeff Greer

Leave a Comment