Friday 27 November 2015

Pi Zero soldering

Well, yesterday was certainly exciting! The launch of Pi Zero was an amazing, fun and rewarding day. I'd tried to warn as many people as I could that they should get down to the shops early or - even better - reserve a copy of The MagPi in advance.

Quite a few of my Y5-6 CodeClub listened and demanded politely asked that their parents get them a copy on their way to work. One boy was amusingly concerned at lunchtime when I told him that some shops had already sold out!

I was also pleased to see that the work we've been doing has got them thinking along the right lines: the first thing they asked when I showed them the Pi Zero was 'how do we connect things to those funny GPIO pins?" I showed them the Pi Zero I had in the Zero Bot and the female header I'd used on that.

When I explained that all you had to do was solder on a header, those who made the DIY Gamer kits last year seemed fairly relaxed. Some of the new clubbers, especially those who hadn't done any soldering before, looked less convinced. Even after showing them the excellent page of instructions in the MagPi, a couple said that it looked really complicated.

So I decided to put together a short video to cover the procedure.  I thought it came out quite well and so I thought I'd share it more widely.

Monday 2 November 2015

Hallowe'en Pis

This year we ended up with three Raspberry Pis powering or controlling our Trick or Treater greeters (scarers).

Spooky Spider

A cheap spider decoration, hollowed out and enhanced with an A+ and a motion sensor that activated  evil red eyes.

The skinny power bank powered the Pi happily for over 4 hours.

The styrofoam body of the spider made it easy to hollow out a cavity for the A+


import RPi.GPIO as GPIO
import time


# Setup the pins we'll use

print "PIR Alarm active (CTRL-C to exit)"

Current_State  = 0
Previous_State = 0


    print "Waiting for PIR to settle ..."

  # Loop until PIR output is 0
    while GPIO.input(GPIO_PIR)==1:
        Current_State  = 0    

    print "  Ready"     
  # Loop until users quits with CTRL-C
    while True :
    # Read PIR state
        Current_State = GPIO.input(GPIO_PIR)
        if Current_State==1 and Previous_State==0:

            # PIR is triggered
            print "  ALARM!"
            # Record previous state
        elif Current_State==0 and Previous_State==1:

        # PIR has returned to ready state
            print "  Ready"
        # Wait for 10 milliseconds
except KeyboardInterrupt:
    print "  Quit" 
    # Reset GPIO settings

A (cute rather than scary) bat that descended from the porch, also activated by a Pi with a motion sensor and lowered by a stepper motor.

The Pimoroni BlackHAT Hackr and the Pi touch display made is really easy to set everything up on the windowseal so that just the wires from the picoborg board could be passed out through the window to the motor. A shaft adapter and some Lego made a nice winding mechanism.

A sinister Lego skull with Pi-controlled blinking eyes.

Why bother building some supports for the breadboards when you can just wedge the LEDs through the eye sockets. I don't know, kids today, eh?

Ozzy wrote the code for this and I thought the use of a simple random function to control the frequency of blinking was particularly effective and gave the impression of a lurking creature rather than just a thing with regular flashing eyes.

import RPi.GPIO as GPIO
import time
import random


def eyes_blinking(pin1,pin2):
    GPIO.output(pin1, GPIO.HIGH)
    GPIO.output(pin2, GPIO.HIGH)
    GPIO.output(pin1, GPIO.LOW)
    GPIO.output(pin2, GPIO.LOW)
counter = 0
while True:
    print ('boo ' + str(counter))