Skip to main content

Python Virtual Maze Solver Robot

 


Autonomous cars are now the most talked topics. Hobbyists try to make them using raspberry pi and computer vision technology. That's an approach. Another but easier way of making autonomous cars are line follower, path follower, maze solver robot. Such robots follow a certain color line drawn in certain environment's floor. We can make them using camera or IR sensor. What if I say that I don't want any line to be drawn on the floor, I want it to run on invisible line. This is what I did here actually. This Virtual Maze Solver/Path follower robot follows a path from a remote PC. So the robot doesn't have any sensors, it just gets coordinates from the PC - where another software robot tries to solve puzzle - and the hardware robot/car moves the way the software robot car moves. Watch the video for better understanding. Let me share now how I made this.



Step 1: Parts You'll Need

Electronics -
  • Arduino Nano (Any board will do, but my PCB supports this) - 1x
  • L298n Motor Driver module (for motor control operation) - 1x
  • Motors - 4x
  • Wheels (Compatible with motors) - 4x
  • HC05 Bluetooth module (to send/receive data) - 1x
  • Multi-functional robot PCB that I made (click here to see) - 1x
  • Some male and female header pins
  • soldering wire (to solder things on the PCB)
To make the body -

  • PVC Sheets (You can use any boards or even papers, I love working with them)
  • Hot Glue and Glue Gun

Software - 
  • Arduino.ide
  • Python3 (Don't worry, I'll guide on how to install that)
That's it. Now let's see how everything will work.

Step 2: Principle (How Everything Will Work)

Simple, the robot will a Bluetooth controlled robot car. A python code will load a map/maze on computer and try to solve it. The hardware robot will get data from Python program using Bluetooth and move accordingly.
The python program will find path by comparing color value. Our map will consist white path. As long as there is a white pixel, the software car will go forward, so will the hardware robot. Now let's make it.


Step 3: Making Robot Chassis

I took some two PVC sheets and cut them according to my need. It's your choice how you want to make it. After cutting the boards/sheets I placed the motors, connected them with proper wires. Both motors of same side acts as one motor, so they are connected together. In image6 I used some female-to-female jumper wires to connect motor control pins to the PCB. After that I added two blue PVC pieces to decorate the body and connected the wheels.

Step 4: Circuit Diagram and PCB


I designed the circuit using EasyEDA. It's simple enough, I left all the analog pins except A4, A5 (those are for I2C communication) and added a SD card reader, bluetooth module and place for Arduino nano. The bluetooth module is separted by jumper (while uploading data, we need to disconnect that). We don't need resistors as Arduino will only receive data, it won't write.

After that I printed the PCB from PCBWay.com. I find their service very impressive. As they offer quality product in less amount of money, I prefer using their service for my PCB's. I went to pcb quick order and uploaded the gerber file. Everything was done automatically by the site. And after my PCB was inspected by their engineers, I paid and got them within 3 days to Bangladesh from China. The quality is amazing, solder mask, lines, glassy look amazes me as always.

Get the PCB from here.

Connections:

  • Left motors to D5, D6
  • Right motors to D3, D4
The Bluetooth module is connected on the dedicated port but to be precise -
  • VCC to 5v
  • Gnd to gnd
  • tx to Arduino Rx
  • Rx to Arduino Tx
What is your sending, is receiving on my end. So Arduino's receiving pin (Rx) is connected to Bluetooth modules sending pin (Tx).
After that powered the PCB from motor driver module. I always like to use a 7.4V power source for my robotics projects. Two lipo batteries will do the job. 3.7+3.7=7.4V, which is ideal for such projects.
So now our bluetooth robot is ready. Next step is programming it.

Step 5: Programming1: Arduino Code

Now it's time to upload the program to the robot. As bluetooth module is connected on hardware serial, I unplugged the jumper before uploading the code.
If it receives -
  • f' goes forward
  • 'b' for backward
  • l' for left and
  • 'r' for right motion
Download the code from here.
Now upload the code using Arduino.ide and proceed to next step.

Step 6: Programmin2: Python Code




I suppose you have python installed on your computer. If you don't, go to python.org/downloads and install latest stable version of python. I use Python3.7.1 as I find it most stable. While downloading download executable installer, and double click it to install, then click on the box that says 'Add python to environment variable path', else you'll be in a disaster.

To send data from the PC to Arduino bluetooth I first connected the bluetooth module to my pc. Steps are -

  • Turn on Bluetooth
  • Go to control panel > device manager
  • Search for new devices
  • Add device (HC05) with password [default password is '0000' or '1234']
Now download the full code from here.

Step 7: Power Up and Let's Go

I powered the robot using two 18650 batteries. Then ran the Python program. How does it perform? You can see that in the video.
The best part of this robot is that you don't need to change robot's code time to time. You just need to change the python program accordingly. That's it.

This robot can be used in industries with some sensors on board to determine errors or in case it slips out of path and also to avoid obstacles. The sky is the limit, your brain is the master.

Downloads:

Get PCB and circuit diagram for this robot from PCBWay: Click here

Code Link: Click here to download.


Comments

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...

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 Scisso...

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...