Skip to main content

Make AI Assistant Robot with Arduino and Python

Introduction:



We all are familiar with ‘Jarvis’ AI assistant robot from “Iron Man’ movies and Marvel series. It has always been a dream of programmers to make something on their own. I will today show a simple way to make such an assistant using Python programming. Moreover, I will also make a physical avatar of that robot, so that whenever we talk to the robot, it can do some movements. That will be more amazing than just a software robot. Because if it has a body, it is cool.

So today we will learn to use both Arduino and Python programming to make an AI robot which can control your computer and have a little chit chat with you. Let’s hop in guys!

Why I named the robot ‘Jaundice’? Because I painted it yellow, very very yellow!

 

Parts:

Electronics -

  • Arduino Nano – 1x
  • Micro Servo Sg90 – 3x
  • Ultra Sonic Sensor HCsr04 – 1x

Body –

  • PVC sheet (preferably white, better for coloring, I used blue one)
  • Servo wheel (for the stand)

Tools - 

  • Cutter knife
  • Scissor
  • Hot glue
  • Spray paint

Software - 

  • Python3
  • Arduino.ide

 

Principle:

Before getting into the actual building, it is great to have an idea of what we will be doing.

So, the main code or AI part of the code will run on the computer, why? Cuz it supports python and has more processing power than the little Arduino, also as the AI bot will control/automate some tasks of my pc it has to run on my pc. So, the Arduino board it connected to my computer using the USB cable.

The idea is to run a  python program that will do the Speech to text part, process the text and will also do Text to speech. Means the robot will listen, understand and talk back. For body movement I saved some movements (encapsulated in functions) in Arduino board. The function for each movements are executed by the python code.

As an example – if the robot has to say ‘Hi/hello’ the python code will send a byte ‘h’, Arduino then execute the hi() function. As simple as that.

Now that you have an idea, let’s move on to next process.

 

Circuits and electronics:

 



Circuits are the things that annoy most makers. If something goes wrong, you may burn some expensive parts. For that I designed a PCB board that can be used to make numerous projects. It has micro SD card slot, Bluetooth module slot, 5v External power source and the whole thing is powered by Arduino Nano.

I designed a PCB using EasyEDA and printed using PCBWay online service. Their service is amazing. I ordered using PCB instant quote and their system automatically did everything for me. Within 3 days I got the board from all the way from China to Bangladesh. The quality is fantastic, solder masking is perfect and the lines/traces, finish is as good as it could be.

Anyway, I used .300 mm traces as it can bear 1Amp current.

You can just download the PCB files from here.


Solder things and test circuit:



In this step I soldered everything. Be very careful not to inhale the fume, it may cause cancer.

I am not using Bluetooth module nor TF module, so I left those unsoldered. The good thing is, I used 3 servo motors and one sonar sensor, all the things get easily powered from the USB cable that we connect to program the Arduino. This is great as we don’t have to think of another power source.

However, if you still want to use external batteries then go for lipo 2s (7.4V) batteries, more than that and the servo burns.


Make the body:





I used PVC sheet to make the body, you can use cardboard too. First, I made a box for the main part, there goes the main board, and servo motors. It is just like making boxes. I made the head the same way, made two hole for the sensor (as eyes). I have added all the pictures you need. I made one hand like a wrench and another one like a plug. I actually used a plug and added that to one arm using hot glue.

Dimension? Actually there is not any, cuz it’s your robot, you can make it using some easy tools so make it as you want, make it of any shape and size.

Be super careful to add all the electronics before closing the body. I painted the body after I put sensors and all the electronics. Do not do that, I already colored my Arduino yellow.

So, do paint after finishing the body, then put all the electronics.

 

Coding1 (Python):



Download Python from this site, make sure to add python into your path while installing.

After installing Python you will need to run some commands from command prompt/terminal to install libraries for Speech Recognition, Audio Support, Text to Speech, Browser Automation, Serial Communication purposes. Run these commands -

pip install speechrecognition

pip install pyaudio

pip install pyttsx3

pip install pywhatkit

pip install pyserial

Then download the python code from here . Head for coding2 step

 

Coding2 (Arduino):

This part is easy, nothing to install. Use Arduino.ide to program the board. Download from here if you have never used Arduino before.

As I have mentioned earlier, Arduino program waits for serial data, if it receives any data it checks the byte data. If data is matched to predefined command then it executes a statement. If ‘u’ is sent, it makes both the hand go up, like that.

Download the code fromhere..

Upload the code.

 

Putting all together And Done:

After completing all those steps I connected my Arduino to pc using the USB cable and then ran the python program. While you are using it make sure to add the right port of Arduino in the python code. If you did everything as I have mentioned, the bot should work just like a charm.

Note: All codes can be downloaded from here.


Comments

  1. Hello please help me. Which app are you using for the python code and also what is the pin out for is? I'm new to this 😥

    ReplyDelete
  2. sir, please respond your code isn't running

    ReplyDelete

Post a Comment