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

Popular posts from this blog

Make a Smart Phone Controlled Robotic Arm ! Arduino DIY.

Making ROBOT ARMs is very popular and fun among hobbyists, but it's not that easy to control a ROBOT ARM. So today we'll be making a robot arm that can be controlled using just your Android Smartphone or tablet. Good news is, you just need to program the Arduino, the App is already available to download for free. Step 1: Parts You'll Need 2 More Images Servo motor 4x (I'm using micro servo Sg90 but any model or size is okay) you can use upto 5 servo for this robot arm, I've only 4, so I'm using them. sliced piece of Card Board - to make the body. USB OTG (on the go) [pic3 & 4- all the same] And of course a Arduino board (any board) And a few jumpers to make the connection And a 9v battery to power the servo motors. Step 2: Making the Robot Arm (THE BODY) Now in here I'm actua...

Make a Smart Humanoid Talking Robot- MOFIZA.

This Robot - Mofiza - (weird name) Can SEE , TALK and REACT to her surroundings. Before I proceed watch the video: Ever since I've seen making talking robots I saw that people actually use other development boards rather than Arduino to make talking robots. But it's completely possible to make a Humanoid robot with Arduino who can talk and add a lot of servos to make it move. So lets begin: Step 1: Parts You'll Need Arduino Pro mini (5v 16 Mhz) [any board is good but i've used this to make it small) Female header pins for connecting on pcb Male header pins Vero Board to make the circuit Sd card TF module (to make it talk) micro sd card (not more than 2GB) 3x IR proximity sensor 3x servo motor (I've used micro servo sg90) Cardboard to make the body Step 2: Connecting IR Sensor and the Body Make a...

Arduino Automated Parking Garage

An Arduino Automated Car Parking System that is too easy and too fun to make. When a car arrives it shows the number of empty slots (if available) and then opens the gate. if there is not any empty slot then the gate does not open.  Amazing thing is that the whole project can just be POWERED using a POWER BANK!! Watch the video for the full tutorial. Note: you can use display instead of my hand made led sign display. Now lets get started. Step 1: Parts Arduino  - any board Infrared proximmity sensor  (pic 2 & 3 - both are functional) 330r resistor some  LED 's Servo motor  - any model or size you wish. Step 2: Making the LED Display To make this  LED display  I have used a piece of bredboard then soldered the LED's and the 330r resistor. Then j...

Problems using PIR sensor?? Always HIGH? DELAY? Solution is here.

PIR sensor When I was working on a project "controlling home appliances using just a wave of hand" I had used a PIR sensor and found some issues: PIR doesn't work properly when starts. PIR output value is always 1. It some times doesn't read motions. Now those are three Common and Unavoidable problems of a PIR sensor. So what would we do? I assume you know what a PIR sensor is and I'll just try to give a solution to the problems so that you can use PIR in your project efficiently, also I've added a code below on how to solve that problem. As I have mentioned earlier those are Common and Unavoidable,  keep 3 issues in mind: After powering - PIR sensor needs 1 minute to function For that 1 minute the OUTPUT is always HIGH. When a motion is detected it'll take 5 to 7 seconds to detect motion again. SOLUTION: After powering - PIR sensor needs 1 minute to function:  which means when you'll power a PIR sensor it wi...

Control Anything Over Internet / WiFi. IOT Light Switch_ NodeMCU ESP8266 .

Parts: NodeMCU ESP8266  WiFi Development Board LED 330r resistor Android app Download the app from Below , To Upload code to NodeMCU using Arduino.ide Update Arduino.ide (desktop app) start Arduino app goto  Files > Preferences  Then  paste the link  then press  ok.    http://arduino.esp8266.com/stable/package_esp8266com_index.json goto  Tools>Boards> Board Manager  then wait untill it finds ESP8266 properties Scroll down and  click install Then Restart the Arduino App. Now you can upload Code in C / C++ to NodeMCU ESP8266 using Arduino.ide Getting IP Address Code T o get the IP Address (Internet Protocol Address) Upload this Code and open serial monitor. #include <ESP8266WiFi.h> const char* ssid="WIFI name"; const char* password = "WIFI PASSWORD"; int ledPin = 13; void setup() { pinMode(ledPin,OUTPUT); digitalWrite(ledPin,LOW); Serial.begin(115200); Serial.print...

How to use ServoTimer2 Library with Arduino- full tutorial.

Introduction I've been trying to make a humanoid robot  MOFIZA -Arduino Talking Humanoid Robot.  recently- which means dealing with Servo motors. Everything worked just as fine just before I tried to make the robot TALK. When I needed to use the TMRpcm library. But there's some libraries like #TMRpcm .h #VirtualWire .h are libraries that use the Timer1 of Arduino. It appears that you can't use two devices simultaneously where both use the same timer...So, if my robot talks- the servos don't work. Because The Servo.h and the TMRpcm both works on Arduino TImer1. Which is a mess. If you want to make both of them work you have to use another library for servos. Which is ServoTimer2 library? This uses the Timer2 on Arduino...Unfortunately on internet I haven't found any tutorials to understand how this ServoTimer2 library actually works, and how to use it in code. So, I've decided to make a tutorial so that people like me can understand better. We'll be u...