Raspberry Pi and Phidgets 8/8/8

Video

A very rough screen capture of the Pi getting data from the Phidgets board for the first time….

Advertisements

Coding time…..

Well, things have progressed somewhat…from a keyboard to a MaKey MaKey was a relatively small step….

Image

After that, I decided that attaching a tiny TFT monitor would be a funky idea…..this opened up a remarkable can of worms, in that the python library I use to read keypresses (PYgame) doesn’t like to run in non-standard resolutions. Anyway…..after a fair bit of digging I got things to work.

374490_10152061660603594_1253841327_n

Now then……a challenge. I love my Phidgets (http://www.phidgets.com/), and using the 8/8/8 interface board as an interface to read analogue sensors into the RasPi has great potential. I hadn’t realised that it involved building all sorts of stuff like Python classes, and I even ended up having to dist off some of my old “C” programming skills….but we got there in the end, and the point where my terminal window told me it could see the interface was a fine moment indeed:

Image

and it got even better when I got the Python script to read the sensor inputs working….here is the output from a simple fader:

Image

Some useful links-

Phidgets and Linux: http://www.phidgets.com/docs/OS_-_Linux

Phidgets and C/C++: http://www.phidgets.com/docs/Language_-_C/C%2B%2B

New project!

Right! Time for a new project. This time, children, I have decided to finally do something with my raspberry pi, and I’m delighted to announce that I’ve just cobbled together my first proper bit of Python that allows me to play different sounds by pressing keys on the keyboard. Here ’tis:

import os
import pygame
pygame.init()
screen = pygame.display.set_mode((100, 100))

while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN and event.key == 97:
os.system(‘mpg321 hang.mp3 &’)
if event.type == pygame.KEYDOWN and event.key == 115:
os.system(‘mpg321 keyser.mp3 &’)
if event.type == pygame.KEYDOWN and event.key == 100:
os.system(‘mpg321 lifter.mp3 &’)

This borrow heavily from this excellent Adafruit tutorial:

http://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/overview

More soon!