PiBug Assembly and Coding

PiBug

Click on any image to enlarge

A barebones, but sturdy, 2WD buggy for the Raspberry Pi, that uses the Pi itself as the chassis for the robot.

Purchase PiBug Here

Assembling the PiBug

Step 0 – Check you have all the parts

  1. Main board
  2. Caster board
  3. Battery board
  4. Battery holder
  5. Castor Pack containing:
    1. Castor ball and housing
    2. Screws: M3, 6mm X 2
    3. Nuts: M3 X 2
  6. Fixings Pack containing:
    1. 22mm F-F pillars X 2
    2. 22mm M-F pillars X 2
    3. 30mm Pillars with holes X 2
    4. 25mm F-F pillars X 2
    5. 9mm M-F pillars X 8
    6. 6mm M2.5 screws X 6 (2 for the caster board)
    7. 30mm M2.5 screws X 4
  7. Motors X 2
  8. Wheels X 2

Step 1 – Attach the Castor to the Castor board

Put the M3 nuts in the holes in the castor housing, then use the 6mm M3 screws to fit the housing tightly to the castor board as shown, with the castor on the bottom and the large 4tronix logo on the top.

Step 2 – Assemble the Motor Mounts

  1. Screw a 22mm Male-Female pillar into a 22mm Female-Female pillar tightly, making a 44mm female-female spacer (remember: 22mm is not the same as 25mm)
  2. Repeat to create a second 44mm spacer
  3. Thread the 30mm screws through the holes in the motor and through the holes in the side of the 30mm pillars, then screw into the 44mm spacers
  4. Important: The 30mm pillars with holes have one end rounded for about 1mm. This is the bottom, the other end is the top that fits to the Raspberry Pi. The rounded end is tapped for M3, and the hex end is tapped for M2.5. Ensure you have these the correct way up
  5. Ensure that the motors shafts are facing outwards as shown in the photo

Step 3 – Fit Motor mounts to Raspberry Pi

You can use either Model A or Model B varieties of Pi. You can’t use a Zero (at least not without some ingenuity…)

  1. In this step we will use 4 of the 9mm pillars
  2. Screw the threaded end of the 9mm pillars through the 2 holes in the SD card end of the Raspberry Pi and into the top of the 30mm pillars of the motor mount assembly
  3. Ensure all screws are tightly fastened

Step 4 – Fit the Castor assembly to Raspberry Pi

  1. Use 2 of the 6mm M2.5 screws to attach the 25mm pillars to the top of the castor board
  2. Use the 2 more of the 9mm pillars and screw through the holes in the Pi into the top of the 25mm pillars as shown

Step 5 – Fit the PiBug Main Board

  1. Push the PiBug main board onto the GPIO connector of the Pi. Ensure all the pins are lined up properly and that the holes on the PiBug board line up with the 9mm pillars
  2. Use the threaded ends of the 4 remaining 9mm male-female pillars to fit the PiBug main board into position.

Step 6 – Fit the Battery Holder Board

Use the 4 remaining 6mm, M2.5 screws to fit the battery holder PCB as shown, with the snap connectors at the USB/ethernet end of the Raspberry Pi

Step 7 – Connecting it up

  1. Connect the JST leads from the motors into the appropriate motor connector on the PiBug board
  2. Fit 6 AA rechargeable batteries into the battery holder and then plug it into the connectors on the battery board.
  3. Note that it will work with alkaline batteries, but when the batteries get low it may suddenly reset the Pi when changing motor direction. This behaviour is better with rechargeable batteries.
  4. We recommend that you use a velcro strap or similar to hold the battery pack in place in case of accidents

Step 8 – Fitting the Optional Line Sensor Board

Use the servo leads to connect the line sensors from the caster board to the male header on the PiBug main board. Ensure the correct orientation of the cable: Brown wire should be on the robot’s right side of the castor board (labelled ‘G’) and on the bottom of the header on the PiBug board (labelled Gnd). Use the leftmost and rightmost positions for the cables

Step 9 – Fitting the Optional Ultrasonic Distance Sensor

  1. Use a HC-SR04+ which is 3.3V compatible. Do not use the older HC-SR04.
  2. Plug it through the 4 holes in the battery board and push it all the way down (see photo above)
  3. The sensor is now connected to pin 20 on the Raspberry Pi

You have now completed the buggy and all you need to do is code it!

Coding PiBug

Pins used:

Left motor: #19, #26

Right motor: #16, #21

Ultrasonic: #20

Line sensors: #04, #27

Tact switch: #13

There are also 2 spare GVS style connectors which you can use for what you want on #17 and #18

A PiBug library module and example code is available by running the following commands in a terminal window on your Pi

  • wget https://4tronix.co.uk/pibug.sh -O pibug.sh
  • bash pibug.sh

 

 

McRoboFace Home Page

McRoboFace – Emoticon for Electronic Creations

mrf02b

(Click on any image to enlarge)

Purchase McRoboFace Here

Overview

The McRoboFace is a robotic face with 17 individually controllable RGB LEDs that you can use to bring your electronic creations to life.

Each LED can be set to any of 16 million different colours (256 for each of Red, Green and Blue).

All the LEDs as fully compatible with the “standard” WS2812, also known as “neopixels” – a name coined by Adafruit. As such, any of the many libraries and examples for most of the common controllers can be used to drive them. This includes:

  • Crumble
  • Arduino
  • micro:bit
  • ESP8266
  • Raspberry Pi
  • Codebug
  • BeagleBone

 

Tour of the ‘Face

v02_Render03

The “mouth” is made up of 14 small (3.5mm) pixels numbered in small lettering from 0 to 13:

  • Lighting 0 to 5 gives a smile
  • Lighting 0, 5, 6, 7, 8, 9 gives a frown
  • Lighting 0, 5, 10, 11, 12, 13 gives a straight-line
  • Use other combinations for quizzical looks, open mouth, etc

The “nose” comprises a small (3.5mm) pixel numbered 14

The “eyes” comprise two standard (5mm) pixels numbered 15 & 16

 

v02_Render04

The rear shows the 3 mounting holes, each is 2.8mm diameter for use with M2.5 screws

There are 4 connections at the bottom:

  • Gnd – Ground pin. Connect to 0V from your controller
  • Vcc – Power pin. Connect to the power pin from your controller.Ideally this is 5V, but on the micro:bit for instance only 3.3V is available. This will work, although it is below the recommended minimum voltage
  • Din – Data input pin. Connect this to the control output from your controller
  • Dout – Data Output pin. Use this to connect additional smart pixels such as another McRoboFace, a CodeBug GlowStar/GlowBug, Crumble Sparkles or an Adafruit neopixel strip etc.

 

Connections to Example Controllers

For the following photos I have soldered on the 4-pin right angle header to make connections easier using jumper leads. Photos are of a prototype McRoboFace, without the numbers to identify each pixel

Crumble

Crumble01

The Crumble knows smart pixels as Sparkles and they must be connected to the D pin. Use the + and – pins to provide Power and Ground

The software is as simple as setting each pixel to the required colour. This is what the picture above is running:

Crumble02

 

Arduino

Arduino01

For the Arduino, any of the output pins will work. In this example we are using A0 as it is closest to the %V and Ground pins.

The code used relies on the well-known and well supported FastLED library. In the Arduino IDE, go to Sketch / Include library / Manage Libraries and then search for FastLED. Select it and install.

Then you can use this example code to show various facial expressions. The important parts are:

  • in setup ( ) – you need to define the number of LEDs, and the pin to be used to control them: FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
  • to change any pixel, set its RGB value in the led array, eg. leds [3] = CRGB (RedValue, GreenValue, BlueValue);  When you have set all the pixels you need, then call FastLED.show ( ); to transfer the changes to the pixels.

 

micro:bit

microbit01

In micro python on the micro:bit, you can use any output pin to control the McRoboFace’s pixels. In this example we’re using Pin 0

As with the Arduino, you first need to include the right library and then define which pin you’ll be using and how many pixels are required. micro:bit calls them “neopixels”

microbit02

 

Raspberry Pi

You can do this in two ways:

  1. Connect directly to GPIO pin and install some software. This software often changes as Raspberry Pi change things in the kernel and will need keeping up to date
  2. Use Picon Zero to provide a simple interface to all your devices including smart pixels

Directly to GPIO Pin

rpi01

You need to use GPIO 18, which is physical pin 12. You can use the 5V and Ground pins directly. No level changers are required as the pixel can be controlled using 3.3V quite happily as shown.

If you already have neopixels supported on your Pi then there is no need for the build and install steps below. You can visit McRoboFace githib repo for the information below

$ git clone https://github.com/4tronix/mcroboface
$ cd ~/mcroboface
$ sudo apt-get install python-pip python-dev
$ sudo python setup.py install

NB. For Raspbian Jessie release 10th May 2016 (and probably later versions also) you will need to add the following lines in ‘/boot/config.txt’ :

hdmi_force_hotplug=1
hdmi_force_edid_audio=1

This will create a folder on your Pi called mcroboface and provide a simple example, mcroboface.py. Run this as:

$ sudo python mcroboface.py

 

Using the 4tronix Picon Zero

rpi02

Picon Zero output 5 can be used to drive smart pixels in a very simple manner. You should first visit the main Picon Zero page to download the library

Download the simple test example from here

 

Singalong Kit for McRoboFace

sa02

The Kickstarter campaign for McRoboFace included an option for some electronics that allowed the mouth of McRoboFace to be controlled by an audio input signal.

This was developed by Robin Newman and the full blog can be seen here

Download the assembly instructions here