CamJam EduKit 3 is available from The Pi Hut (assuming they have stock!)
The controller is available from The Pi Hut and costs £14, making it comparable with other low-cost controllers.
First of all, take your CamJam EduKit 3 and build your robot.
If you have not already done so, write an SD card with the newest Raspbian image from the Raspberry Pi website. I recommend the "with desktop" version. I recommend Etcher as the method for writing the image as it doesn't require you to unzip the image file before you write it to the SD card.
Once you've written the SD card, put it back in the machine you used to write it. If you're on Windows ignore anything about needing to format the SD card.
On the "boot" partition, create a file called ssh
. This will allow you to remotely connect to your Pi should you need to.
Also on the boot partition, create a file called wpa_supplicant.conf
and put into it the following:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="MY_SSID"
scan_ssid=1
psk="MY_PASSWORD"
key_mgmt=WPA-PSK
}
Replace MY_SSID
with your wifi router's SSID and MY_PASSWORD
with your wifi router's password.
This will connect your Pi up to your network and allow you to install the extra software you need.
Insert your SD card into your Raspberry Pi and connect up a keyboard and monitor.
Plug in the Pi and boot it up.
With any luck, you'll be connected to your network.
Login to the Pi using username pi
and password raspberry
Type ifconfig
and check you've got an IP address on your wifi device.
Type in the following commands to install the required software. Depending on whether you’re running Raspbian (full) or Raspbian Lite, some of it may already be installed.
sudo apt update
sudo apt install python3-pip
We’re going to be using GPIO Zero plus Tom Oinn (Approximate Engineering)’s input
library to communicate between the
controller and the motor controller. You can read the documentation for input
here.
sudo apt install python3-gpiozero
sudo apt install python3-dev gcc
sudo pip3 install approxeng.input
This last command loads the library and enables the root (superuser) to run it, which we will need to auto-start the code later.
Now, grab the example script to run your CamJam EduKit 3 robot:
wget https://github.com/ApproxEng/approxeng.input/raw/master/scripts/camjamedukit3.py
Plug in your Pi Hut controller’s USB dongle.
Turn on your Pi Hut controller by activating the switch on the underside.
Type in the following to test out the connection between the controller and the Pi:
python3 camjamedukit3.py
You should see GPIO Zero being found followed by the controller being found. Press a few buttons on the controller to see the commands come through. Press the ‘Analog’ button to exit the script. (The script actually says use the HOME button, but the Analog button is that button!)
To control the motors on your robot, just use the left-hand analog stick. You might consider changing the script eventually to do some kind of dual stick movement, but until then, just use the left stick.
Now, we need to make the script start up when the Pi is turned on.
Edit the rc.local file by doing:
sudo nano /etc/rc.local
Before the exit 0 statement at the bottom, add the following:
/usr/bin/python3 /home/pi/camjamedukit3.py &
If the rc.local method fails (and only if it fails),
First of all, edit the rc.local file and remove the line you added.
Then, open up a Terminal and type the following:
crontab -e
Choose the Nano editor if it asks you (it should, if it's the first time you've done it). Now, to the bottom of the file, add the following:
@reboot python3 /home/pi/camjamedukit3.py &
IMPORTANT: Make sure you put that & at the end otherwise your Pi won't continue to boot!
Save the file and exit. Reboot and it should run the script.
Make sure to add the & at the end!
Save the file and then shutdown your Pi:
sudo halt
Now, on the next reboot, the script should run. This means that now is the ideal time to detach the Pi from the keyboard and power supply and re-integrate it into your robot. You could also switch to a Pi Zero at this point. Don’t forget to move the USB dongle over to the Zero if you’re doing this!
You should find that the controller now controls your robot!