Introduction: Knight Rider Lunchbox Robot

Ok, it doesn't talk, it isn't black and doesn't have AI. But it does have those fancy red LED's in the front.

I build a WiFi controllable robot which consist of a Raspberry Pi with WiFi adapter and an Arduino Uno. You can SSH into the Raspberry Pi and control the Arduino with a Python Tkinter script over serial. Asides from driving you can also control front/rear lights, signal left/right and turn on those cool Knight Rider LED's!

Step 1: What's for Lunch? AKA Tools and Materials

Lot's of the material's are available on BangGood.com. They're cheap and they have almost everything. You can find the rest on Ebay and some in your local hardware store.

Materials:

Tools:

  • Hot glue pistol
  • Super glue
  • Screwdriver

Important: I used modified servo's for the wheels. You can also buy normal motor's but then you'll have to alter the Arduino code.

Step 2: Preparing Your Lunch

So I had to saw of the fake "wheels" where to lunchbox rests on.

After that I added the servo's and wheels on the lunchbox (hot glued the wheels on the servo's). I used popsicle sticks because they were perfect to rest the servo's on. After that I added the powerbank. On top of the powerbank I added 2 popsicle sticks with a caster (super glued the caster on the popsicles sticks). On the back of the powerbank comes the Arduino Uno. On top of the powerbank comes the Raspberry Pi (in a case) and on top of that the breadboard. I fixated everything with double sided tape. Last I screwed on 2 fake robot wheels on the front.

Step 3: Fitting the LED's

I drilled holes of 5mm everywhere I wanted to place LED's. The LED's I used have a diameter of 5mm so they fitted perfectly! I used:

  • 2 red for the tail lights
  • 2 white for the reverse lights
  • 6 red for the Knight Rider LED's
  • 2 white for the front lights
  • 4 orange for the signal lights.

Step 4: The Wiring

Well the hardest part of the project was fitting the wiring inside to lunchbox.There are a lot of wires especially for the LED's. For the LED's I used male to female breadboard wires, that way you don't have to solder anything. For the rest I used male to male.

The Raspberry Pi and Arduino are connected by USB. I made a Fritzing example and did my best to make it as clear as possible.

Step 5: Preparing the Raspberry Pi

For anyone who is a bit familiar with the Raspberry Pi and Linux this should be a peace of cake. I used Raspian to power the Pi. It has python3 with the modules tkinter and pyserial pre-installed (we need this to control the Arduino)

  • Go to the official Raspberry Pi site and download the latest Raspbian.
  • Flash the latest Raspbian to you micro sd (there is a installation guide on the download site).
  • Plug in a internet cable and WiFi adapter and power on the Pi.

Now we need to configuring the Pi to auto connect on WiFi when in headless mode.

  • Find out the IP address of your Raspberry Pi with one of these methods.
    • Nmap, (this works best on linux).
    • Login to your router to see the connected devices.
    • Use a smartphone app like "Fing" to scan your network for connected devices.
    • Alternative method: connect you Pi to a monitor and keyboard and use the ifconfig command to show your IP.
  • If you're on Linux you can use a terminal to SSH into your pi, if your on windows you should download putty.
  • Once connected and logged in (username: pi password: raspberry). type in the following
sudo nano /etc/network/interfaces
  • Delete the existing lines and paste the following lines in the file (replace SSID with your own SSID and replace password with your WiFi password, keep the quotes!).
auto lo 
iface lo inet loopback
iface eth0 inet dhcp 

allow-hotplug wlan0
auto wlan0 iface 

wlan0 inet dhcp
   	wpa-ssid "SSID" 
	wpa-psk "password"
  • Reboot the Raspberry Pi and hopefully it will automatically connect to your WiFi network (remember that your IP address will change once you're connected through WiFi instead of wired).

Step 6: The Coding

You can get the files from my github:

https://github.com/InfiniteFor/KnightRiderRobot

Upload the Wifi_BOT.ino file to your Arduino

  • connect the Arduino to your pc/laptop.
  • open the WiFi_BOT.ino file with the official Arduino software and click upload.

Copy the control.py script to your Raspberry Pi.

  • Open the control.py with a text editor.
  • SSH into you pi and type:
nano control.py
  • Past the code from the control.py into your newly created python script and save it.

Step 7: X11 Forwarding for Remote Control

You need to forward X11 for the python script to work from your laptop/pc. This is because a normal SSH session doesn't forward X11 by default.

When you're on Linux this is really simple. Just apply the -X or -Y (whichever one works) in your command line. For example:

ssh -X  pi@<rpi-ip-address>

When on windows you have to complete a view other steps. Besides putty you also need to download xming. There is a really great guide on how to use xming with putty. http://www.geo.mtu.edu/geoschem/docs/putty_instal...

Step 8: Lunchtime!

  • Power on your Arduino (9v battery) and Raspberry Pi (power bank).
  • Wait for the Raspberry Pi to start up.
  • SSH into you Raspberry Pi (don't forget to forward X11) and type in:
python3 control.py

Enjoy!

Besides the buttons you can also press the key's on your keyboard. Those will instantly be send to your Arduino.

Future ideas:

I had so much inspiration for this project but couldn't do them all. So here's a short list of other things you could do:

  • Connect a camera to the Raspberry Pi and watch the feed from a webpage.
  • Instead of a python tkinter script you could make a http page which you can access to control the robot. You can even show the camera feed in the same page! (no X11 forwarding needed for this method)
  • With port-forwarding you can control your robot from anywhere in the world!
  • Instead of connecting the Pi to your home network you can create a hotspot on the Pi. That way you're not limited to your home network.

Please let me know if you like this project. Also feel free to ask any questions you have!

Raspberry Pi Contest 2016

Runner Up in the
Raspberry Pi Contest 2016