Building a PiCy

I've been trying to build a PiCy which I can control from my laptop (HP Pavilion G6 running Windows 7). The parts I'm using are mainly from your website: 2 wheels/motors, 4xAA battery holder, voltage regulator and picoborg. My wifi dongle is a Edimax EW-7811UN 150Mbps Wireless Nano USB Adapter and has been set up and used prior to my PiCy attempts. My pi is from RS components and the chassis (perspex) and wire are from a hardware store. Using your guides I've constructed a model of it, however when I try to use your RemoteKeyBorg code to operate it i get no response. My laptop is using Python 2.7.5 and the matching Pygame 2.7 software to run RemoteKeyBorgC and my raspberry pi and picoborg both seem happy running off the battery pack I'm using (4xAA wired with a voltage regulator and on/off switch). It runs RemoteKeyBorgS as an executable file and the terminal comes up with 'You can now turn on the power, press ENTER to continue' then once I have done so and I try to input commands on my laptop keyboard (while both RemoteKeyBorgC/S are running) nothing happens. I'm not sure if I'm missing something obvious or if I have missed a step out but any advice would be appreciated!

piborg's picture

  1. Can you ping the Raspberry Pi from the laptop, try:
    ping -t from a command prompt,
    replacing the IP address with the one from your Raspberry Pi.
    Does the ping work, or does it come back with an error?
  2. Does the Raspberry Pi reset / lose connection when commanding the PiCy, try:
    ping -t from a command prompt,
    replacing the IP address with the one from your Raspberry Pi.
    With the ping still running load and try to move, does the ping get interrupted?
  3. Finally try setting the IP address in
    line 10 should have broadcastIP, change the value to your Raspberry Pi's actual IP, e.g.
    broadcastIP = ''           # IP address to send to, 255 in one or more positions is a broadcast / wild-card

    if the Raspberry Pi has an IP address of

Thanks for getting back to me so quickly! Your suggestions have been very helpful in narrowing down my issue. I've run a few pings to my pi's IP and all have come back with perfect connections, even when also running the RemoteKeyBorg codes. I do now get a response from my pi when I press the esc key while try to control my PiCy however still no wheel movement. So could it be an issue with my power supply not reaching the motors? The pi still runs off my battery pack so I'm happy that they still have power and that my soldered connections are ok but i can't think what else it could be..?

piborg's picture

  • Is your left motor connected to M1+ and M1- ?
  • Is your right motor connected to M4+ and M4- ?
  • It could be a wiring problem, could you upload an image of the layout and / or photos of the connections.

Do I use the IP and port I connect to my Raspberry Pi via SSH?

By the way, my wiring is working whenever I use your script "". I type a combination of 5,6 & 7 to make it go straight, left and right. But your "" is not working for me. I might be doing something wrong though, I'm running "" on SSH and trying to use the arrow keys. :)

piborg's picture

RemoteKeyBorg comes in two halves, a server and a client.

The server,, must be running on the Raspberry Pi using sudo, this will run inside an SSH terminal, remember to press ENTER when you see the message You can now turn on the power, press ENTER to continue before trying to control PiCy.
The server should be left running until you are finished using PiCy.

The client,, tries to open a window to catch key presses, therefore it has to be run in a graphical environment.
The value for broadcastIP is best set to the IP address you are using for logging in via SSH.
If you are getting the error pygame.error: Unable to open a console terminal this means it cannot render a graphical display, so it will not work.
There are three ways around this problem:

  1. Run locally, it should run fine under Windows as well as Linux, but you may need to install Python and pygame first.
  2. Use a graphical login to the Raspberry Pi, such as VNC or RDP, this will provide a graphical environment to log in to
  3. Enable X11 forwarding for SSH, this may be effort but will allow you to use SSH as intended.

To setup VNC and RDP

wget -O vncserver
sudo apt-get -y install tightvncserver
sudo cp vncserver /etc/init.d/vncserver
sudo chmod a+x /etc/init.d/vncserver
sudo update-rc.d vncserver defaults
su pi -c /usr/bin/vncserver
sudo chown pi:pi /home/pi/.Xauthority
sudo apt-get -y install xrdp

When you are asked for a password enter a login password to use for VNC logins, we recommend the same password you use to login with SSH.
When you are asked if you want to enyet a view-only password, we recommend you reply no (n).
To connect to the Raspberry Pi graphically you can use Remote Desktop Connection on windows, or you can use a VNC program such as TightVNC.

To use X11 forwarding over SSH
You will need an X11 server program on the machine you are SSHing from.
If you are using Linux this will mostly likely be setup already.
If you are using Windows you will need to install an X11 server, we would recommend using Xming.
You will also need to enable X11 forwarding on the SSH program used, see the attached image if using PuTTY.


Now, this is clear! Thanks for the clear instructions.

Can you give instructions on how to use RemoteKeyBorgC.pyn on a Mac? Thanks!

piborg's picture

You should just need Python and pygame installed for the script to work, both seem to provide Mac OS X compatible versions so it should be simple enough.
Unfortunately I do not have a Mac to test it with though.

If you need SSH to perform X11 forwarding you need to use the -X switch (the same is true for Linux), e.g.
ssh -X pi@

I'm having difficulty installing Pygame on my Mac OS X 10.5.8 with Python 2.5.1. I've downloaded "" and it's giving me an error "You cannot install pygame 1.9.1release on this volume. pygame requires System Python 2.5 to install."

I tried several times and I'm stuck. :( Anyway, not your problem but I would appreciate an advice.

Just in case nothing works for me. Is it possible to write a script that runs on Terminal and responds to key presses? :D

piborg's picture

It sounds like there is a copy of Python provided by Apple and that it is not entirely compatible with the normal download copy of Python.
Do you know which you are using?

I would try using the X11 forwarding on SSH, that way the program runs on the Raspberry Pi itself:
ssh -X pi@
then load the RemoteKeyBorgC script, if it works then the pygame screen should appear.
Someone else has suggested if the -X switch does not work to try
ssh -Y pi@
The Raspberry Pi should already have pygame installed if you are running Raspbian.

Thanks piborg! This is what I did:

Using Mac OSX Terminal:

Step #1
1) Open Terminal
2) SSH to your Raspberry Pi
3) Type: sudo python

Step #2
1) Open another Terminal window
2) Type: ssh -X pi@XXX.XXX.X.X
3) Type: su - pi
4) Enter your password
5) Type: python

piborg's picture

Glad to hear it can be made to work properly on Mac OS X :)

Not to mention that it's simple and easy. Now I can easily navigate my rover anywhere with the Pi camera and RemoteKeyBorg. Great job piborg!

Subscribe to Comments for "Building a PiCy"