Pizazz – Sample programs in Python and ScratchGPIO

Python Example Scripts

Please note that these programs are provided “as is” and without warranty purely for the purpose of demonstrating how you can write your own code for this robotic vehicle.

If you have our SD card with ready-installed demos, you will find these programs in home/pi/Pizazz/

If not then from a terminal window (eg. LXTerminal) type or cut&paste the following to install:

wget http://4tronix.co.uk/pizazz.sh -O pizazz.sh

bash pizazz.sh

  • motorTest.py  Tests the motors by moving Forwards, Reverse, SpinRight, SpinLeft, Pause in a loop. Press Ctrl-C to exit. This program will also light the LEDs to show the direction it is moving. Two LEDs at the front for Forwards, 2 LEDs at Left for Spin Left, etc
  • ledTest.py  Simply tests the LEDs by cycling LED1, then LED2, then LED3 then LED4 then back to LED1 again. Press Ctrl-C to stop
  • sonarTest.py  Prints the distance from the ultrasonic sensor to the nearest reflective obstacle. Repeats every second. Press Ctrlc-C to stop
  • standardLF.py  This is a standard Line Follower algorithm (thanks to Zachary Igielman). Place a black line (eg. electrical insulation tape) onto a reflective surface and the Pizazz will check if either sensor hits the line. If, say, the left sensor touches the line, then the Pizazz will spin left until the sensor is no longer on the line, then it will start moving again. You may need to adjust the separation of the sensors, and/or the speed of the robot to follow your specific line
  • fuzzyLF.py  This line follower is a bistable line follower. It is always (after it has found the line) either turning left or turning right. If it hits a line with the left sensor then it know it needs to turn left to find the line again, so it keeps moving left until the right sensor detects a line, then it starts moving right. This has the strange effect of the Pizazz wandering around close to the line, but not necessarily sitting directly over it. It does mean the that the speeds can be increased and it is easy to make the Pizazz go around a track twice as fast as with a standard line follower. You probably will need to move the line follower sensors much closer together than for the standard line follower program


ScratchGPIO Example Scripts

Please note that these programs are provided “as is” and without warranty purely for the purpose of demonstrating how you can write your own code for this robotic vehicle.

If you have our SD card with read-installed demos, you will find these scripts by doing a File / Open within Scratch and selecting the Pizazz folder

Many thanks to Simon Walters (@cymplecy) for all his excellent work on this

Programming the Pizazz – Which Pins do What


Pizazz – A Robot Vehicle for your Pi, Complete with Sensors and Optional WiFi

Allocation of GPIO Pins

The following list of pin numbers assumes that you have exactly followed the wiring instructions here

For ease of use with ScratchGPIO all pins are specified as the physical pins on the GPIO header. In brackets, we put the standard Broadcom use of these pins

  • Left Motor: 24 (CE0), 26 (CE1). To move forwards set 26 to High and 24 to Low. (NB it is better to use PWM to get some speed control)
  • Right Motor: 19 (MOSI), 21 (MISO). To move forwards set 19 to High and 21 to Low. (NB it is better to use PWM to get some speed control)
  • LED1: 22 (GPIO25). Set Low to turn On, set to High to turn Off
  • LED2: 18 (GPIO24). Set Low to turn On, set to High to turn Off
  • LED3: 11 (GPIO17). Set Low to turn On, set to High to turn Off
  • LED4: 07 (GPIO04). Set Low to turn On, set to High to turn Off
  • UltraSonic: 08 (TXD). Set to an Output to send a 10µs pulse, then set to an Input to measure the return pulse
  • Left Line Follower: 13. This will be Low (0) for White (reflective) surface, and High (1) for Black (non-reflective) surface
  • Right Line Follower: 12. This will be Low (0) for White (reflective) surface, and High (1) for Black (non-reflective) surface


Using Batteries for the Pizazz

  • Although all other parts of the Pizazz will operate purely from 5V supplied to the USB connector on your Pi, you will need to connect the battery pack to the MicRoCon and switch it on, before the motors will operate
  • You should only use good quality rechargeable batteries that can provide at least 1A continuously. We strongly recommend Energizer Extreme rechargeables of at least 2000mAh
  • the MicRoCon has a voltage regulator which will happily and safely power your Pi as long as the battery voltage remains above 6V or so
  • If the batteries are getting low, you should safely turn off the Pi, then remove and recharge the batteries
  • You can also power the Pi and the motors from separate power sources if required. Unsolder the solder jumper on the MicRoCon (near the regulator) labelled PWR, then you can power the Pi by plugging in a USB power bank or similar into the the USB socket on the Pi – NB. You will still need to connect batteries for the motors to operate


Using the Motors

  • Each motor is driven by 2 separate GPIO lines
  • To make the motor move, one of these lines needs to be High and the Other needs to be Low
  • If they are both the same (either both High, or both Low) then the motor will not turn
  • To move the Pizazz forwards in a straight line: Set 19 and 26 High, and set 21 and 24 Low
  • To move the Pizazz backwards in a straight line: Set 19 and 26 Low, and set 21 and 24 High
  • To Spin Left on the spot, make the Left Motor move backwards and the Right motor move forwards: Set 26 Low, 24 High and set 19 High, 21 Low


ScratchGPIO Examples

You will require ScratchGPIO version 5.1.26 or later, and see here for tutorial examples



Pizazz Low Cost Robotic Vehicle for Raspberry Pi


Pizazz – A Robot Vehicle for your Pi, Complete with Sensors and Optional WiFi


All true robots need some form of input sensors and outputs as well as motors, so we have created this ultra-cheap but full featured robot for your Raspberry Pi. Just look at some of the features:

  • Crystal Clear Pizazz chassis in 3mm acrylic plate
  • 2 pre-wired 48:1 geared motors, complete with noise suppression capacitors
  • No soldering, glueing or adhesive pads etc. All items simply plug or screw together
  • Fully assembled MicRoCon2 controller board – Optional Extended Header if required (select during purchase)
  • Low drop out voltage regulator to safely power your Pi and keep the power separate from the motors. No requirement for two separate battery packs
  • Custom designed 4tronix ultrasonic and LED PCB for easy fitting of the ultrasonic distance sensor and provide 4  individually controllable output LEDs
  • LEDs can be driven directly using Python or ScratchGPIO commands
  • InfraRed line sensors with adjustable positions
  • Wifi dongle (optional)
  • 6-cell battery holder
  • On-Off switch
  • All the wires, screws and mountings required
  • We also offer an optional SD card pre-loaded with ScratchGPIO, VNC, Python and example files in Pyhon and ScratchGPIO so you can get going straight-away
  • All you need to provide is the Raspberry Pi and the batteries

Links to Get you Started

Assembling Pizazz Robot for Raspberry Pi

Pizazz Assembly Instructions

NB. Click on any image to enlarge

1. First check you have all the parts


  • Main acrylic chassis plate with pre-wired battery pack and switch
  • Two motors with attached wires and noise suppression capacitors
  • 2 Wheels
  • Bag containing front caster wheel and mountings
  • 2 x line sensors
  • MicRoCon robotics controller board (assembled)
  • Ultrasonic and LED board (assembled)
  • 2 x 3-way 20cm jumper leads
  • 2 x 2-way 30cm jumper leads
  • 4-way 30cm jumper lead


2. Fit battery holder to chassis


  • Remove the brown protective paper from the acrylic chassis plate
  • Push the switch into the hole until it clicks into place
  • Use 2 countersunk 12mm M3 screws and nuts to fit the battery holder. Ensure that the head of the screws lies flat inside the holder so that batteries fit in properly


3. Attach the motors


You require:

  • 4 x Motor mounts, after removing the brown protective paper
  • 4 x M3 30mm screws
  • 4 x M3 nuts
  • 2 x Motors


  • Mount the motors on tyhe bottom of the chassis plate (opposite side to battery holder)
  • For each motor, insert one motor mount through the slot in the top and the other sits in the slot on the edge of the chassis plate
  • Mount each motor with the wires on the outside as shown in the photo above
  • Push the 30mm screws in from the outside and attach the nuts on the insert
  • Make sure the motors a fitted flush to the chassis plate and do not move around


4. Fit the mounts for the Raspberry Pi


You will need:

  • 2 x 10mm hex spacers
  • 2 x M3 6mm pan head screws (to mount the spacer to the chassis plate)
  • 2 x M3 6mm countersunk screws (to mount the Pi to the spacers)


View from underneath showing the Pi mounted (don’t mount it now as you will need to remove for the next step)


5. Mount the Caster Wheel


You will need:

  • 4 x 10mm hex pillar (brass)
  • 8 x M3 8mm screws (pan head)


  • Screw the 4 pillars onto the bottom of the chassis plate using the holes shown above
  • Screw the wheel assembly into the pillars


6. Mount the Raspberry Pi and MicRoCon


  • Mount the Raspberry Pi to the pillars, using the countersunk M3 6mm screws
  • Push the wires from the switch/battery holder and the 2 motors through the holes in the chassis plate as shown


  • Push the MicRoCon onto the GPIO header of the Raspberry Pi. **Be very careful to ensure the pins are all correctly aligned **
  • Connect the battery wires to the front terminal block as shown: Red to Vin and Black to Gnd
  • Connect the left and right motors to the side terminal blocks. Note the colours of wires in the photo above:
    • Black is nearest the rear on the left side
    • Red is nearest the rear on the right side
  • If you wire these differently, then you will have to change all the example code for it to work correctly


7. Mount the ultrasonic Board


You will need:

  • Ultrasonic and LED board (assembled). Note that you probably have Blue, Green, White LEDs and no Red LED. this is intentional
  • 2 x M3 6mm screws (pan head)
  • 2 x M3 nuts


  • Screw the ultrasonic board into the top of the chassis plate, using the hole positions shown


8. Fit the Line Follower Sensors


You will need:

  • 2 x line follower sensors (with adjustable sensitivity)
  • 2 x 25mm hex pillars
  • 4 x M3 6mm screws (pan head)


  • Use the holes nearer the middle of the line follower sensors
  • Arrange the sensors so the LEDs are pointing downwards
  • The terminal pins should be pointing towards the rear of the chassis


 9. Wire in the Ultrasonic Board


  • Use the 30cm 4-way cable
  • Connect:
    • Brown to Gnd
    • Red to Echo
    • Orange to Trig
    • Yellow to Vcc


  • Use the 2 x 30cm 2-way cables
  • Connect:
    • Green to LED1
    • Blue to LED2
    • Violet to LED3
    • Grey to LED4


  • On the MicRoCon ultrasonic connector, connect:
    • Brown to Gnd
    • Red to Echo
    • Orange to Ping
    • Yellow to 5V
  • On the “Sig” pins next to the ultrasonic connector, connect:
    • Blue to 18 (physical GPIO pin 18)
    • Green to 22 (this is physical GPIO pin 22)
  • On the “Sig” pins on the 3V3 block of 4 x 3-way pins, connect:
    • Violet to 11 (physical pin 11)
    • Grey to 07 (physical pin 7)


Step 10. Wire in the Line Followers


  • Left Line follower (shown from underneath, so it appears on the right in the photo), connect:
    • Yellow to Gnd
    • Green to V+
    • Blue to S (Signal)
  • Right Line follower, connect:
    • Brown to Gnd
    • Red to V+
    • Orange to S (Signal)


  • Right Line Follower sensor cable, connect to Pin 12 connections:
    • Brown to Gnd
    • Red to 3V3
    • Orange to Sig
  • Left Line Follower sensor cable, connect to Pin 13 connections:
    • Yellow to Gnd
    • Green to 3V3
    • Blue to Sig

11. Attach the Wheels – All Finished!


NB. When pushing the wheels onto the motors, you MUST hold the motor and not the chassis, otherwise you are likely to break the motor mounts.

Now you can add the batteries, plug in your SD card and start programming


Battery Power Issues for Small Robots on Raspberry Pi


When using a robotics controller board with small DC motors on Raspberry Pi, you need to consider how you will power it in such a way as to minimise cost, weight, complexity and maximise flexibility, reliability and power.

These two sets of requirements are not necessarily mutually inclusive. In this article, I discuss three options and try to give the pros and cons objectively and factually:

  1. Power the Pi and the Motors directly from the same 5V power source
  2. Power the Pi from a 5V power source and the Motors from a separate power source (voltage to suit)
  3. Use a voltage to suit the Motors and a regulator to create the 5V for the Pi

For all of this we are assuming the use of small DC motors like these:


At 6V, these require 120mA running, but stall current can be as high as 500mA


1. Powering Pi & Motors from Same 5V Power Source

This is not recommended.


  1. You can use a simple 5V USB power source


  1. Pi will suffer when the motor takes excess current. Simply starting the motor could generate enough of a glitch to cause a problem: network interface is likely to be lost first
  2. When the battery voltage gets too low the motors will just go slower, but the Pi will stop and can easily corrupt the SD card
  3. With an inductive load – even using flyback diodes – the spikes on the 5V line can cause serious problems and potentially damage the Pi


2. Powering Pi & Motors from Completely Separate Power Source

This is a highly safe solution – recommended in many scenarios


  1. You can use exactly the right power source for both components: 5V USB power for the Pi, any voltage/current source for the Motors
  2. No wasted energy (heat) so nothing gets hotter than it needs to
  3. Can design smaller control boards as no need for voltage regulator, associated components or heatsink
  4. Easier to support as no issues with regulators


  1. You need two sources of power 5V
  2. More expensive solution as you need the same batteries as solution 3, plus something like a USB power bank
  3. Heavier solution – small models may not be able to take the 2 sets of batteries


3. Powering Motors from Battery Pack and use 5V Regulator for the Pi

This solution is recommended in some scenarios


  1. Only a single battery source needs to be used
  2. Only one battery pack to recharge or switch on and off
  3. Reduces weight and overall product cost


  1. When the power gets too low, the Pi will stop and potentially corrupt the SD card
  2. Regulators get hot. At least, linear regulators get hot – switching regulators (see Mo-Pi) are a lot more efficient. Typically 90% or so.


4. How Hot do Regulators Get and Why?

This is the killer question and is the main reason that I recommend using separate power supplies (Option 2 above) in many situations.

Linear regulators take an input voltage (say 7.2V nominal for 6 rechargeable cells) and output a fixed voltage (5V for our Raspberry Pi). To do this, they effectively act as a resistor which automatically varies to keep the output voltage constant. We all know Ohm’s law: V = I x R. The power (heat) of the resistor is easily given as V x I. So if the input voltage is 7.2V, the output voltage is 5V and the current used by the Pi is 0.7A, then the power dissipated by the regulator is: (7.2-5.0) * 0.7 = 1.54W

Now 1.5W doesn’t sound very much, but unless you have some way of dissipating that heat, the temperature will only increase. For small input voltages of 7.2V and less, you may be able to do without a heatsink. However, to dissipate this heat properly you should use a heatsink. We generally use a small one that is rated at 21°C / W. This means that thermal equilibrium is reached at a temperature of 21°C above ambient temperature for every Watt that is dissipated. For the 1.54W above, this means that the temperature of the regulator and heatsink would be 32°C above the ambient temperature. This is warm, but is acceptable and definitely within the relevant British Standards.

The problems come when a) the input voltage is a lot higher than 7.2V, or b) the Pi takes a lot more power than 0.7A. So you should:

  • Keep the input voltage down to something reasonable. We recommend 6 cells of rechargeable batteries as a maximum (ie. 7.2V nominal)
  • Note that the regulator needs some voltage “headroom” to work with. Some require a minimum input voltage of 2.5V above the output voltage (eg. 7805) so that means you have to put in more volts and thus generate more heat. (we use the L4940V5 which has a minimum input voltage of 6V)
  • Do not overload the 5V (or 3.3V) on the Pi with lots of directly powered addons
  • Use a heatsink if planning on using for extended periods (ie. more than a few minutes minutes at a time)

Finally, the power taken by the motors is irrelevant as far as the heat generated in the regulator goes. It will affect the driver chip of course, but that is a different issue entirely and not to be confused.


Getting to Know Your MicRoCon

MicRoCon – Micro Robotics Controller for Raspberry Pi


This is the baby sister to our full-featured PiRoCon controller board. It still features two bi-directional motor controllers, a 5V regulator for the Raspberry Pi as well as general purpose IO connectors, 5V servo outputs and a 4-pin Ultrasonic input.

Motors A & B

  • Motor A: Pins 24, 26 (GPIO: CE0 and CE1)
  • Motor B: Pins 19, 21 (GPIO: MOSI, MISO)
  • Permanently enabled
  • Use either pin for each motor with PWM
  • Remember to invert the PWM duty cycle when reversing
  • Motors are driven via an L293D H-Bridge chip from the input voltage at the 2-pin terminal (not from the regulated 5V supply)


 GPIO Connections

  • These are NOT level-shifted and only work with 3.3V devices. Do not connect a 5V input
  • Each GPIO pin has an asdsociated Ground and 3.3V pin so can connect 3-pin sensors directly
  • Pin 7 (GPIO: 04)
  • Pin 11 (GPIO: 17)
  • Pin 12 (GPIO: 18)
  • Pin 13 (GPIO: 27)



  • These 2 sets of 3 pins provide outputs to drive 5V servos
  • The signals are not level-shifted but all servos I have tried work happily with a 3.3V input signal
  • Servo 1: Pin 18 (GPIO 22)
  • Servo 2: Pin 22 (GPIO 25)


Ultrasonic Input

  • These four pins allow an HC-SR04 4-pin ultrasonic sensor to be connected directly
  • This uses a resistor network to allow the sensor to use only a single GPIO pin, which is shared between Ping/Trig and Echo
  • Output a pulse using the pin in output mode
  • Then switch to input mode to await the response
  • This is connected to Pin 8 (GPIO: Txd)



  • This uses an L4040V5 linear low dropout regulator
  • The input voltage can go as low as 6V and the output will remain at 5V
  • The higher the input voltage, the hotter the regulator will get in use
  • The motors do not use the regulated voltage so will have no effect on the temperature of the regulator


I2C Female Header

  • Allows easy access to the I2C signals SCL and SDA
  • Also provides 0V, 3.3V and 5V connections
  • Same pinout as used on the PiRoCon expansion header so all expansion boards for the PiRoCon can also be fitted to the MicRoCon – ADC, 16-channel PWM available right now.
  • You can use the 4tronix IP Display dongle directly into this header.


Return to MicRoCon Home

4tronix Initio Home Page

About 4tronix Initio


The Initio 4WD robot platform has been specially designed here in the UK to work easily with Arduino and Raspberry Pi controllers. Supporting products include motor driver boards, sensor shields, sensors, pan-tilt mechanisms and more. We also have a range of kits available for both Arduino and Raspberry Pi platforms

Outline Specification

  • An extremely flexible and easy to use 4WD Robot platform designed by 4tronix especially for Raspberry Pi and Arduino
  • Injection moulded from tough ABS
  • Built-in powerful 170-size motors and high-quality gearboxes
  • Arduino (UNO, Mega2560 or Leonardo) and Raspberry Pi mount directly onto the base-plate
  • 6-cell battery box with switch, charging socket, wiring for motor driver and Arduino already in place
  • Built-in speed encoders on each side with electronics already fitted
  • Each wheel can be individually decoupled from the gearbox – run as 1WD, 2WD or 3WD if you want!
  • Fixings for stepper motors (28BYJ-48 as found in our shop – not included) so you can replace the DC Motors with stepper motors for greater accuracy
  • No soldering or gluing required – simply screw together and plug in the wires (of course you can add things we haven’t thought of and they may need soldering)
  • The main chassis is delivered ready-built and all wires connected
  • All you need to do is add in the control boards and screw on the top plate
  • Mounting plates included for IR obstacle sensors and Line sensors
  • Loads of extra mountings for additional boards included


Purchasing Initio

4tronix Initio Assembly


Online Guides:

Other Assembly Information

Downloadable PDF Guides:



Motors Not Turning

  • For Raspberry Pi, ensure you are using correct software. Use the software in “robohat” folder if using RoboHat, or in “initio” folder if using Pirocon
  • Batteries. You must use good quality rechargeable batteries, not alkaline. We strongly recommend Energizer Extreme 2300mAH




4tronix Initio Programming Examples


Arduino examples are found in our Arduino support site

  • initio_01 simply moves initio back and forwards and spins
  • initio_02 uses PWM to control the speed and create smooth turns
  • initio_03 shows how to use the speed sensors to move accurate distances
  • EncoderTest01 tests the operation of both wheel sensors. Use the switches on the top of the gearbox to disengage the wheels from the gears, then turn the wheels by hand to see the results on the serial monitor
  • initio_04 uses the obstacle sensors to avoid obstacles
  • initio_05 adds a light-follower function using LDRs mounted on the Pan/Tilt (Connect one end of each LDR to 0V, the other ends to A0..A3)
  • initio_06 uses the line sensors to follow a black line and stop when it reaches a cross-roads
  • initio_07 uses the ultrasonic sensor mounted on the Pan/Tilt to avoid obstacles and travel in the direction of most space



Raspberry Pi ScratchGPIO examples are found in our GitHub

  • MotorTestB.sb    Allows control of the motors using arrow keys (ScratchGPIO)
  • PanTiltTest.sb    Allows moving the pan/tilt assembly using arrow keys (ScratchGPIO)
  • UltraSonicTest.sb    Shows operation of the UltraSonic sensor (ScartchGPIO)
  • TrackerTest.sb    Uses the ultrasonic sensor on a Pan/Tilt assembly to follow (ScratchGPIO)
  • Avoider.sb    Uses IR obstacle sensors and motors to avoid objects (ScratchGPIO)
  • InitioTest.sb    Uses line sensors, obstacles sensors and motors (ScartchGPIO)
  • Also see this post for using the wheel sensors with Raspberry Pi and the PiRoCon


Raspberry Pi Python examples can be downloaded from an LXterminal session and connected to the internet, type in or copy and paste:.

wget https://4tronix.co.uk/robohat.sh -O robohat.sh

Then type in:

bash robohat.sh

You will then have a number of python examples in the robohat folder to try. Run them with:

sudo python filename.py
  • motorTest2.py:  use the arrow keys to move forwards and backwards, spin left or spin right. Space to stop. Use . and , to increase or decrease speed
  • sonarTest.py: Prints the distance in centimetres from the ultrasonic sensor, once every second
  • irTest.py: Prints the state of the IR line and obstacles sensors, every time the state changes.
  • servoTest.py:  use the arrow keys to pan and tilt

NB. If using the older Pirocon controller the replace robohat with initio throughout the above.


Yes, you can now program the Initio for Raspberry Pi directly in C. What’s more, it works seamlessly with both the Pirocon and the RoboHat control boards so your program can work on either without being changed

Visit this link to find out more about this which was written by Dr Raimund Kirner at the University of Hertfordshire




PiRoCon Robotics Controller – Links

Links for Various Resources for the 4tronix PiRoCon



If you are experiencing low power to the motors when using the DC Jack input, it is very likely that you have not set the power selection jumper correctly to the right as shown below:



New: PiRoCon v2 released



  • Pins 15 & 16 (Broadcom GPIOs 22 and 23) are swapped from what is shown on the silk screen
  • Pin 11 is shown as GPIO 07 on the jumper bank, instead of GPIO 17


Getting to Know Your PiRoCon

Tour of PiRoCon

In this post we will take a tour around the PiRoCon v2 board and see how all the various elements operate and can be configured



Power Supply


  • The DC Jack (bottom left) is the input connection for your battery voltage. The voltage should be between 7V and 12V and will need to be able to supply at least 2A. This is a 2.1mm DC Jack with positive centre pin. Below about 6.5V, the regulator will not be able to output the 5V required for the Raspberry Pi to work. Above 12V, the regulator will probably get too hot.
  • The voltage regulator (lower left side) is used to convert the input voltage to 5V as required by the Raspberry Pi. For version 2 of PiRoCon we use a switching regulator which barely gets warm even at higher input voltages and no heatsink is required. Note that the motors are not powered from the regulated power supply


Motor Drivers


  • The terminals for two DC motors are at the top right of the board. Motor A on the left and Motor B on the right
  • Both terminals are wired the same way (left to right) so the same inputs would drive the motors in the same direction. If you use one motor for a left side drive on a robot and the other for a right side drive, then you should swap the wiring for the second motor. For instance, using the example programs on the Initio, you should wire Red-Black-Black-Red
  • The motor terminals are driven directly from the output of the H-Bridge driver chip L293DD (shown just below the motor terminals)
  • The 4 GPIO pins used to drive the chip are the SPI pins CE0, CE1, MISO and MOSI. These are connected via solder jumpers (to left of the L293D) – these are pins 19, 21, 24, 26
  • If you want to use other pins to drive the motors, then you should cut these these connections and wire your own connections to the required positions
  • Each motor has an enable pin which by default is connected directly to 5V using the jumpers just above the solder jumpers and below the 8×3 header block. For some purposes it is better to use the enable pins for the PWM signal, so that you can use the 4 control pins to purely control the direction. If you want to do that, then you should remove the jumpers and wire the enable pins to a PWM source (eg. an Adafruit 16-channel PWM board plugged into the PiRoCon expansion sockets)
  • In the bottom right of the photo above is a separate 2-pin terminal for external power. If you don’t want to drive the motors from the incoming battery voltage on the DC jack, you can move the selection jumper (just above the 2-pin terminal) and provide your motor voltage directly to the 2-pin terminal. This voltage can be from 5V-15V DC – ensure you connect it the correct way round. Note that this 2-pin terminal does NOT power the 5V regulator, only the motors.
  • For normal operation using the DC jack input. ensure the jumper is placed to the right side, or no power will get to the motors


5V GPIO Connector (8×3 rows)


  • NOTE: The Ground pin for the 8×3 block of GPIO pins is at the lower side for v2 PiRoCon (upper side for v1), so be careful when wiring
  • There are 8 unallocated GPIO pins available and these are brought out to a bank of 8×3 male headers
  • The headers are at 0.1″ pitch so you can connect standard 3-pin 5V sensors or servos etc. directly to them
  • Each signal is separately fed through a bidirectional level converter so can safely be used to input or output at 5V
  • Each signal is labelled with an x-number (on the jumper block) and a #-number
    • x refers to the physical pin number on the GPIO connector. So the first signal on the left is x07 which is pin 7 on the GPIO connector
    • # refers to the GPIO number itself. So the first signal (x07) is GPIO#04
  • Each signal can be disconnected from the GPIO header to the Raspberry Pi, by removing the relevant 2-pin jumper (shown top left)
    • If you remove the jumper, then the related signal in the bank of 8×3 is no longer in use
    • You should then connect a 3.3v max input or output to the signal pin where the jumper was
    • This allows the use of 3.3V sensors (eg. the wheels sensors on the Initio)
    • There is a 2-pin header (top left) which has two 3.3V connections, intended for powering 3.3V sensors
  1. #04 – x07
  2. #17 – x11
  3. #18 – x12
  4. #27 – x13
  5. #23 – x16 NB. Labelled incorrectly on board as #22
  6. #22 – x15 NB. Labelled incorrectly on board as #23
  7. #24 – x18
  8. #25 – x22

Please note, as described above, there is a layout mistake on the PCB which results in pins 15 and 16 (GPIO numbers 22 and 23) being swapped. So ensure that you plug into the correct connection for your application

Ultrasonic Sensor


  • There is a group of 4 pins (shown above at top right) that are designed to add an HC-SR04 ultrasonic sensor directly to
  • From the left, these are 5V, Trig, Echo, Gnd and match the ordering of the pins on the sensor
  • There are 3 resistors which process the signals so that both Trigger and Echo can use the same GPIO pin on the Raspberry Pi and also that this is 3.3V safe
  • The jumper (just below and left of the ultrasonic 4-pin connector) can be used to select either TXD (pin 8) or SCLK (pin 23)
  • If you want to use a completely different pin, simply remove the jumper completely and connect the pin you want to use to the centre pin of these 3


SPI Connector


This 8-pin female header allows you to connect the SPI signals. Note however that these are also used for motor controls by default, so you may need to attach the motors to different pins if you want to use SPI. Alternatively, simply don’t connect the motors when using SPI.

  1. 5V
  2. 3.3V
  3. CE1
  4. CE0
  5. SCLK
  6. MISO
  7. MOSI
  8. GND


I2C Connector


This 6-pin female header allows you to connect additional modules using the I2C connections. These are not used on the PiRoCon itself, although the expansion boards (see below) can use them. This connector also has the UART RXD/TXD pins on together with Gnd and 3.3V

  1. Gnd
  2. RXD
  3. TXD
  4. SDA
  5. SCL
  6. 3.3V


Expansion Board Sockets


There are two 6-pin expansions sockets that use I2C connections to add functionality to the PiRoCon. Expansion boards available right now are:

  • 4-channel analog input (ADC) with single channel analog output (DAC) from 4tronix



  • 16-channel PWM or servo driver from Adafruit



If you use stacking headers for the 6-pin connectors, and right-angle headers for the signals on the boards, you can stack these I2C expansion boards as much as you like. Here are both the above expansion boards fitted: