Creating an App to Control a Robot via Voice Command and Gyroscope

 Creating an App to Control a Robot via Voice Command and Gyroscope


Today, we will see how to use voice commands and a Gyroscope to control a robot with an app.

So, the robot works with the help of an LDR and a transistor. The robot consists of two wheels controlled by an LDR and a Transistor. The robot will have a mobile stand on top of it where the phone will be placed. The phone would've a screen where two black coloured blocks turn white according to our command, and due to its whitening, the LDR detects light, and with the help of the Transistor, the wheel would start rotating, making the robot go forward, turn right and left and stop. 

We won't learn how to make the robot, but we'll learn to create an app using the MIT App Inventor to control it. 

What you'll need:
  • A Mobile Phone
  • A Laptop
Step 1: Designing the layout of our app

First, open the MIT App Inventor website and click on 'New Project'. Then, rename it to 'Gyroscope_Voice_Command'. 
After that, first add a button on screen1  and then set its width to 'Automatic'. Then, add a Canvas to the Screen and change its height and width to Fill Parent. Upload an image to Canvas. The images are provided in the following Google Drive link- https://drive.google.com/drive/folders/1lDy59om-8CODnh4uoe1oLz_xPYYSrSzc?usp=drive_link. From the images, upload the image 'Robot Face'. 
After that, upload the remaining images in the 'Media' option. 

Then, add a Horizontal Arrangement and change its height to 40 per cent and width to fill the parent. Then, add 2 buttons. Change their widths to 50 per cent. Change the buttons default colour to black and shape to rectangle. 

Lastly, add 4 Non-Visible Components - Speech Recogniser, Text-to-speech, Clock and a Gyroscope sensor tool. 


















Our layout design is ready.

Now let's add the code.

Step 2: Writing the code.

I've provided step-by-step images of the code to be uploaded. Write the code according to the images.

























































































After that, click on 'Build' and then click on 'Android App(.apk)' and then you'll be able to download your app. After downloading it, you can scan the QR code to download the app on your mobile phone, too. 
And lastly, go to 'Projects' and then click on 'Export selected project (.aia) to my computer. This will help in opening your project whenever you want it on any computer temporarily.

The App Is Ready!


Comments