If you have been waiting for your Pi-Car and just want to try and make it do something as quick as possible start here.
This Jump start assumes that you have a Raspberry Pi up and running and you are able to able to access the screen with the big Raspberry Pi showing on it:
If you have not yet got this far don’t worry there is loads of help – you can start with our guide to getting up and running by clicking here.
If you do not really understand what a Pi-Car is then click here.
Connect your Pi-Car up
Connect cable to radio controller – make sure that it is pushed in securely.
Connect cable to Raspberry Pi – make sure it is the right way round. On one side of the long black connector is a raised square this should be on the side facing the rest of the Raspberry Pi.
Start your Raspberry Pi and get to the screen with the big raspberry on it (remember at the login prompt that appears when you turn it on type pi and then press enter and type raspberry as the password and press enter. After this type startx) For a full guide click here.
Get something happening
This part does involve writing some lines of Python code – if you don’t fancy this it maybe best to start with the Scratch tutorial.
If you can’t view the video the instructions are below.
Click on the LX terminal and type:
This should bring up a prompt that looks like the following
You next need to tell Python that it will be using the GPIO pins so it can get ready to do it. Type and press enter:
import RPi.GPIO as GPIO
Remember capitalisation is important – if it is lower case above type it in as lower case, ditto with upper case.
Next you need to tell python to get the GPIO board ready you do this by typing (and pressing enter after)
The final bit of preparation is that you have to tell the GPIO pin that it is an output pin rather than an input one. Type the following in
The GPIO pins can be used to output, or send, signals down a cable to something else – like the Pi-Car controller or they can receive a signal from something. Here we are using them as outputs and the line of code above says that.
So we are now ready to actually send something to the Pi-Car. To turn the GPIO pin on and off you set it to 1 to turn it on and 0 to turn it off. Type in the following to turn pin 11 on.
When you do this your Pi-Car should lurch backwards! To stop it lurching backwards type the following:
You may have noticed that you can use the up and down arrows in the Python terminal to go to the last entry you typed in and then edit it. You can also always turn your Pi-Car off or disconnect the connector if you get in a muddle!
You can now test the remaining GPIO pins. Remember to set them up first:
GPIO.setup(12, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(15, GPIO.OUT)
You can then try each one individually by outputting to them as you did earlier:
- GPIO pin 11 – backwards
- GPIO pin 12 – forwards
- GPIO pin 13 – left
- GPIO pin 15 – right
When you are finished playing around run the following command to clean up the GPIO pins.
This ensures they are left in a good state. If you do get stuck you can always just disconnect your Pi-Car or turn your Raspberry Pi off and on again – call it a ‘Power Cycle’ and you are pretty much a real Engineer already.
Well done if you have got this far. If not don’t panic, check the following things:
- Is the Pi-Car cable connected securely
- Can you control the car from the controller – you should be able to even when it is connected to the Raspberry Pi
- Is the Pi-Car turned on?
- Did you get any errors when you typed in the Python code
If you are still stuck just leave a comment or email us at firstname.lastname@example.org.
PDF version of this article – Jump start – get your Pi-Car going as quickly as you can with Python _ Pi-Cars