This is a notebook of projects I attempt with a Raspberry Pi or wearable technology

About me

In the photo I am in the blue blouse. It's taken on the famous little railway to Shimla. I'm a Code Club volunteer and love messing about with computing and particularly coding in Scratch. I want to get into 'maker' stuff using my Raspberry Pi but I'm a complete newbie. I am learning a bit about electronic making by going to Leeds Raspberry Jam once a month. I'm looking to do a robot project with the Raspberry Pi Zero in the future. I've just started an adventure to code wearable LEDs using an Adafruit Gemma. And I've been lucky to have been given a CodeBug so I'm learning to use that too!

Author: Anne Carlill

In the photo I am in the blue blouse. It's taken on the famous little railway to Shimla. I'm a Code Club volunteer and love messing about with computing and particularly coding in Scratch. I want to get into 'maker' stuff using my Raspberry Pi but I'm a complete newbie. I am learning a bit about electronic making by going to Leeds Raspberry Jam once a month. I'm looking to do a robot project with the Raspberry Pi Zero in the future. I've just started an adventure to code wearable LEDs using an Adafruit Gemma. And I've been lucky to have been given a CodeBug so I'm learning to use that too!

I expected this to be difficult to do – as you usually have to type something into LX Terminal to get your Pi to recognise the dongle – but it wasn’t. However it was not plain sailing. I couldn’t get the first wifi dongle, I bought, to work and spent ages, with other help, trying to get the software to recognise it, all to no avail. Either I’d got a dongle that wasn’t compatible with an R Pi or it simply didn’t work. I’ll never know!

However, once I’d bought the official Raspberry Pi wifi dongle it was totally straightforward!

That is, after I’d sorted out the amount of power needed. I connected my USB hub up to the Pi and switched on the hub’s power. Once I had done that it worked perfectly.

Now I can find recipes and cook with my little R Pi and HDMIPi screen in the kitchen and, also, sing very loudly to my heart’s content along with Choir! Choir! Choir! in the front room, where there’s no router. Aren’t you glad you’re not here!

It’s brilliant!

PS If you want to use the dongle with a Pi Zero, (like I did because when I bought a Pi Zero with ready-soldered header from Pi-Supply they had no Pi ZeroWs) you need a:

The next stage in making the robot rover I’m constructing (with massive help from the Cam Jam people and their EduKit3) is to incorporate ‘power on the move’ for the PiZero.

As you read before in A robot rover using a PiZero – Part 1 the two powered wheels use 4 x AA batteries. However no independent power source for the Pi is included with the kit. You therefore have to choose and buy the one that suits you. Because I am using a piZero rather than a full-sized Pi, I can get away with a lower power battery source (which adds less weight) than you would need for the full-sized Pi. I therefore chose a 2200 mAh (milli Amp hours) DC 5V portable powerbank. These are meant for powering smartphones on the move. They are often called lipstick battery packs (because they’re like a large lipstick) and can be bought at high street discount stores.

I went to a trusted online Pi provider though, because I can’t afford to get it wrong and damage the rest of the set-up. Also, the Pi provider’s powerbank came with the micro USB cable to charge it up with (and link it to the PiZero).

Anyway, the powerbank came immediately and, after a charge-up of about 4 hours (using the plug from my smartphone), its light went out to show it was fully charged and it is working brilliantly. You just disconnect the cable and turn it around so the standard USB goes in the ‘OUTPUT’ on the powerbank and the micro USB goes into the Pi.

PiWars is an event like Robot Wars, which you may have seen on TV, but without the destruction. If you think that sounds boring you need to find out about the great courses the PiWars team put the robots through. I particularly enjoyed the ‘balloon popping’ one.

After visiting PiWars, I decided I had to have a go at making a robot rover myself. Not being that clever and allergic to soldering, I decided to buy a kit. (Well not literally allergic but absolutely useless at it!)

Here are my costings:

This assumes you’ve got some sort of Raspberry Pi already. So you’ve got a power supply, keyboard, mouse, screen and powered USB hub – all with cables.

I am pleased to say that the wheels turned when I tried it, so I must have done all the electronics correctly, and Michael & Tim’s instructions are excellent! It’s the first time I’ve understood everything in a project’s materials.

Here’s the Python code I used (The indenting hasn’t come out here):

import RPi.GPIO as GPIO

import time

# Set the GPIO modes

GPIO.setmode(GPIO.BCM)

GPIO.setwarnings(False)

# Set variables for GPIO pins

pinMotorAForwards = 9

pinMotorABackwards = 10

pinMotorBForwards = 7

pinMotorBBackwards = 8

# Set the GPIO Pin mode

GPIO.setup(pinMotorAForwards, GPIO.OUT)

GPIO.setup(pinMotorABackwards, GPIO.OUT)

GPIO.setup(pinMotorBForwards, GPIO.OUT)

GPIO.setup(pinMotorBBackwards, GPIO.OUT)

# Turn all motors off

def StopMotors():

GPIO.output(pinMotorAForwards, 0)

GPIO.output(pinMotorABackwards, 0)

GPIO.output(pinMotorBForwards, 0)

GPIO.output(pinMotorBBackwards, 0)

# Turn both motors forwards

def Forwards():

GPIO.output(pinMotorAForwards, 1)

GPIO.output(pinMotorABackwards, 0)

GPIO.output(pinMotorBForwards, 1)

GPIO.output(pinMotorBBackwards, 0)

# Turn both motors backwards

def Backwards():

GPIO.output(pinMotorAForwards, 0)

GPIO.output(pinMotorABackwards, 1)

GPIO.output(pinMotorBForwards, 0)

GPIO.output(pinMotorBBackwards, 1)

Forwards()

time.sleep(1)

Backwards()

time.sleep(1)

StopMotors()

GPIO.cleanup()

The only bit I was stuck on was finding instructions to start the code working automatically, once I’d separated the PiZero from it’s cables and switched on the battery box. I expect you have to use some sudo commands in the LX Terminal. Apparently I need to use this post: Raspberry Pi’s Linux Documentation which explains the correct commands to start up the PiZero and run my python code automatically.

Well, I feel I’ve made great progress today – so separating PiZero from it’s cables, and getting it to start the code (which moves the wheels) automatically, will be in Part 2.

Happy R Pi tinkering!

PS You can now buy PiZeros, with the male header already soldered on, from Pi-Supply .

These two were animating a cat and dog and learnt how to resize and move their cat and dog sprites- getting their sprites to turn around at the edge of the screen. They also worked out the basic control blocks you need to make your code work.

and used it to go further into Scratch. A variation of the Boat Race game, which is explained in the book, resulted in a maze game that we enjoyed.

Boat Race game

Next time we need to get involved in physical computing, perhaps, using BBC micro:bits or the Pibrella. However I’m looking forward to seeing some more complete beginners because the more adults and children who know what coding is all about, the better!

I was asking a question about screen brightness today and it was stated ‘… make sure SPI is enabled’.

I didn’t know what SPI was. It appears to stand for Serial Peripheral Interface. It looks as if it needs to be enabled to send data in both directions, e.g., from the R Pi to the screen and from the screen to the R Pi. I would have thought this was a vital job of an OS so I am not sure why it wouldn’t be enabled already.