Wednesday, 30 December 2015

Daleks, cameras, and a mutant rabbit.

A little more detail on my experience of PiCademy and some of the code developed (and I apologies it is not well developed).

Programming LEDs and Motors through either the the GPIO or using an HAT (see the images below) is just what I enjoy the most.

To have a go, you may have to have the following:

In the above image was my attempt at a simple 'Dalek' - essentially a cup and straw, with a wheeled motor inside. Controlled using python,  Pi through an Explorer HAT PRO . It essentially moved in a circle either clockwise (button 1 on the explorehat) or anti-clockwise (button 2).

import explorerhat
from time import sleep
from random import randint

def wheel(channel, event):
    duration = randint(1,2)

def wheel2(channel, event):
    duration = randint(1,2)

It needs a lot more work, not least of which is a moving head under seperate motor control but it is a start.

Playing with the PiCamera and a button attached to the GPIO, I came up with a simple system that everytime the button is pressed a image is captured this was based on the activities and worksheets at PiCademy. The extra was the tweak concerning providing a different filename each time. Essentially:

  •  create a string with most of the filename and path ('/home/pi/Desktop/image'); 
  • include a count of how many pictures have been taken and convert that to a string (str(count)); 
  • add the file extension ('.jpg');
  • combine them and use them as the filename.

The whole code is shown here.

from time import sleep
from picamera import PiCamera
from gpiozero import Button

camera = PiCamera()
button = Button(17)

while True:

Rise of Rabbitsapien - A team of us put together a project of a robot with a rabbit (no other soft toys were available) with a Passive IR sensor in its belly; that carries out a set routine when movement is detected.

It was also great to come away with some many resources both physical and activities. Thank you to the Pi Foundation for such a good experience.

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.

Gesture controlled python robot unicorn (or is it a rhino)

In the previous two post I built and played with a robot unicorn from  Do it Kits . In the first...