Showing posts with label Project. Show all posts
Showing posts with label Project. Show all posts

Thursday, 19 May 2016

Hack the Teacher - A lesson in physical computing using a Raspberry Pi Zero Christmas Jumper

Just before Christmas I had some fun with a Christmas Jumper and Physical computing based around the (then) new Raspberry Pi Zero. Here is the rather belated write up of the lesson.



I was not quick enough to get hold of a Magpi issue 40 when they were first in the shops so I subscribed and waited for it to be delivered to my door. Initially I didn't really know why I wanted the attached free Raspberry pi Zero, I just knew I wanted one.

The Jumper


However when it arrived inspiration arrived with it and I decided I needed to make a Christmas jumper and that it would be a really good tool to get some of my students interested in programming. I came up with a simple plan of a Christmas tree with some lights and set about creating the base for the project.

This was all going well apart from two factors; I now only had a weekend to complete the project to be able to use the jumper in lessons (before the end of term), and my inability to sew.

Not one to be daunted I found some felt and cut out the basic shapes then had a crash course from my wife on how to attache them using needle and thread. So I eventually (after a late night sewing) managed to attache the tree using a simple running stitch in the centre of the tree and then added blanket stitch around the edge to secure it in place (and add decoration). From a distance the effect was relatively respectable. (if you look closely you can see that the quality of my blanket stitch improves as it goes around)

The second evening I spent setting up the electronics. I played with a couple of different configurations but in the end decided on individually programmable LEDs. Each LED is connected to a separate pin on the Pi Zero and to Ground. This left maximum flexibility in what could be done with the lights.


I had initially thought about hiding all the connections inside the jumper but as I was putting it all together I quite liked the idea of it all being visible. To this end all of the wiring was attached to the front of the jumper and the Pi Zero itself was sewn onto the jumper. I also used a portable USB power supply to allow me to walk around without being tethered to a plug socket.





After getting it all wired up I connected the PiZero up to a monitor and set about creating a test program that would show the lights on the tree working. It could also be used as a starting point for the students to modify the existing code to create their own sequences. To make it a little easier I set up a few functions that set groups of light as on or off and the made a short sequence using the functions. I set this up to start on boot so I could just connect the power and the light sequence would start.





The video shows one of the LEDs had failed but this proved to be a loose wire that was hastily soldered up and everything was up and running.

The Lesson

The idea for a lesson using the jumper was inspired by last years code.org hour of code which had students programming a sequence of lights for Christmas trees outside the Whitehouse.

The plan was to explain how the GPIO library is used to turn the lights on and off and then let the students view the code for the existing sequence before coming up with their own code to control the jumpers LEDs.

Preparation

To allow students access to the PiZero I needed to connect it up to the school network. The plan was to do this over wireless with a USB wireless network adapter. (in reality I had problems getting onto the school WiFi network so I took off the jumper and used a wired adapter instead) The students could then login to the PiZero using SSH and use nano to create their programs.

The students downloaded putty to their workstations in order to do this.

Introduction
Demonstration of the jumper working

Explanation of GPIO Library commands to control the LEDs (including the functions I created earlier)

Main Activity
Students to design an algorithm for the light sequence

Students to use python and the GPIO library to program the sequence - this was done by logging in over SSH using putty and copying the basic file (including the functions and GPIO setup) giving it their own name.

Students test the code on the jumper - this required a bit of co-ordination to ensure we only ran one script at a time.

Extension
Able students create their own functions that they can reuse in their sequence.


Plenary
Demonstration of some of the best (aesthetically) sequences

Discussion about code efficiency and creation of functions to avoid duplication of code


Review

The lesson went well with a good deal of enthusiasm generated by the idea of 'hacking the teacher' the students were initially very overly excited by downloading putty and being able to log in remotely to the Raspberry Pi on my jumper.

The students were fairly quick to be able to get a short piece of code working (mostly just a single flashing LED) and then move on to experimenting with using the functions I had built.

At this stage there was a good deal of discussion about what they could do that would be amusing (fortunately I had thought of this at the design stage and I think I managed to avoid any embarrassing light combinations of a phallic nature, or at least they didn't find any during the lesson). Once they had discovered they could not create anything rude they settled for pretty and started to compete on who could create the best sequence.

There was lots of experimentation of how fast they could get lights to flash or change and with what sort of changes looked good. Some of this was a little held up by the fact that there was only one jumper so students occasionally had to wait for someone else to test their code before they could run theirs. It might have been good to have some breadboard prototypes for testing to reduce some of the waiting but i feel that that may have spoiled the interest provided by making the code run on my jumper. This would have been even better if we could have got on over wireless and I could have been walking around the room whilst they were testing their code on me but this was a small niggle.

Overall the lesson was a great success with students engaged in creating code and experimenting to see what they could do as they learnt more about how the Library worked. There were some great creative responses and some good use of functions with parameters for time that could be reused at different points in the code.

If i did this again with another class I would probably use the GPIO Zero library to reduce the code required to get things working but with students staring by using my example code they had a reasonable start anyway.


The rest of the day as I walked around school I did spend alot of time assuring students (and some staff) that "No it's not a bomb" (it was just after Ahmed's clock incident) and "No I won't catch fire". However I did get several question about how it was made and could they make one too, so hopefully some more students aware of the possibilities of computing.

Friday, 24 July 2015

The PiCycle an amazing student project



I have had the pleasure this year to have been a supervisor for one of our sixth form students doing an Extended Project Qualification (EPQ).

The EPQ is a level 3 qualification (similar to A-level) for students to do something that they are interested in. This can be an essay or an artifact and can take a myriad of forms. In this case my student chose to do a Raspberry Pi based project which was how I became involved.

Dan had no previous experience of the Raspberry Pi or Python before starting the project. He had done some web development but wanted to try something new. He spent a large portion of the project time mastering the basics of Python and the basic hardware before moving on to getting the project up and running.


The result is the PiCycle a Raspberry Pi based cycle computer that takes the position of the rider an plots it on a map on a website. The idea was to use the device to prove the designer had completed a planned charity cycle ride across France but could be used for all sorts of tracking applications. As well as getting the device working he spent some time getting it to look good too with branded interfaces on the device and the web tracking page.





The student developed the program to collect the GPS position and store this in a file on the Raspberry Pi and then upload the data to the web to display the position(s). The design means that whilst the cyclist is in areas of poor phone reception they can still log the GPS position (assuming GPS signal) and then upload the data when the phone signal is regained.

This project was a great achievement especially considering that Dan had no prior knowledge of the Raspberry Pi or Python before he started the EPQ.

Some more information about the project can be found in his project presentation. He can be found on twitter: @DJWOOLFALL.

Wednesday, 29 April 2015

Sci Fi Your Pi a design Challenge from Element14

After my success in the Raspberry Pi Educators Roadtest winning the prize for the UK (an Up mini 3D printer) I thought I would put in a proposal for their latest design challenge.

The title of the design challenge is "Sci Fi Your Pi" and centres around the idea of creating objects from or inspired by Science Fiction. This video explains what it is all about

I struggled initially to think of anything interesting being stuck on the suggestions made in the introduction to the challenge. However it was my search for difference that gave me the idea of looking at creating a Steampunk inspired device.

The kit for the challenge comes with a GPS model so this along with the strong adventurer spirit in Steampunk fiction I ended up with the idea of a Navigation device.

My idea has been selected from a large number of applicants among a very interesting group of projects. So far I have outlined my initial inspiration and described what I am hoping to produce for the challenge.  I have received the kit and I am putting together a plan of how I am going to make it work.



For anyone not familiar with Steampunk this video gives a fairly good introduction through a number of film clips. 



The spirit of adventure and exploration (as exemplified by the work of HG Wells and Joules Verne) felt like a great basis for a project where I will be trying new things and creating something a bit different to some of my other projects.

You can follow my progress on the Element 14 community with the tag steampunk_navigation

Tuesday, 10 March 2015

Agobo The Hackable Raspberry Pi Robot - now with emotions





My wife gave me a 4Tronix AgoBo robot kit for Christmas (at my request). I built it a few weeks ago but didn't really have time to do anything with it.

The AgoBo is a Raspberry Pi A+ based robot kit. I also ordered the Plus plate that adds a Neopixel and lots of prototyping space on a board that mounts above the RPi. The kit is a really good affordable robot kit that can be customised very easily, especially with the PlusPlate. It is this customisation that really attracted me to the AgoBo in the first place.

When the robot arrived I thought that the Ultrasonic sensor looked like a pair of eyes but AgoBo was lacking a mouth. On another evening I was rooting through a box of electronic bits I bought for RPi projects and found an 8x8  LED matrix. 


I had seen plenty of robot that used these as eyes and thought that this could work. However with the robot being so small the matrix was far too large. I had another dig in the box and found a more suitably sized replacement.


The 5011AS display fitted just below the ultra sonic sensor with the pins above and below the main board. Aligned horizontally the segments could be used to make a smile or sad face by lighting the correct segments.

This idea was put on the back burner for a couple of weeks whilst normal life got in the way. and I kept thinking about how to mount the module effectively under the board. When I was able to experiment with the robot again (finally loaded the example software and tried out the supplied python scripts) I couldn't resist having a try with the mouth idea.

I haven't found time to solder the header on to the plus plate yet and wanted to get the mouth working so I grabbed a breadboard and some cables to try it out before I sorted it all out properly.



I had a ten cable female to female ribbon so I divided that into two (5 cables in each) to connect the ten pins of the display. With the ends of the cable connected there was very little room between the pins but with a little blue tack the display mounted nicely with two pins each side below the board and three above. To keep things tidy I separated the first part of the cable for a short length and then wrapped the cable up over RPi and under the PlusPlate (with a little Blue Tack of course).







I then grabbed a few resistors and connected the cables to the breadboard and then connected the other side to the header I fitted to the main board (in preparation for connecting the plus plate).


This is where I ran into my first problem.limited time and a failure to read instructions lead to an error in the connections. Instead of looking at the instructions I looked at the numbers on the top of the PlusPlate and reading down from the top started used the first available pins. Unfortunately these pins are already in use by AgoBo so there was a bit of a conflict when I tried to use these to run the mouth.

So looking back at the instructions I made a list of the pins that were in use and looked again at the PlusPlate for available pins and moved the connections to pins that were not already in use by AgoBo.

Once I had the connections all set up (correctly this time) I needed to set up- the code to run the mouth and control the facial expressions. I decided i wanted a smile (obviously, what's cuter than a smiling robot?) a sad face, a confused face and an open mouth, After this time consulting the instructions (the data sheet from Jameco) I drew a little diagram of which pin controlled which segments of the display and worked out a little table of which should be displayed for each facial expression.



With this organised I set up a Python library (mouth.py) to set up the facial expression and then a quick script to test the expressions. The test script (mouthtest.py) shows each expression I have set up so far. the smile, sad face and 'oh' i am really pleased with. I am not to sure about the confused face so I may not use that very much. These scripts will be available from my AgoBo Github fork here.


.



With the mouth working I wanted to work the expressions in to the normal running program for Agobo. I had written a quick script previously for him to avoid objects using the ultra sonic sensor so I used this as a starting point.

I ran into a small issue here as I had set up the mouth library using GPIO numbers and the AgoBo library is set up using board numbers. after a little head scratching (I am still unsure why in an error state the face always seems to display 'oh') I spotted the error and changed the mouth library to match the python library and now Agobo will avoid objects whilst displaying his emotions.

Currently he is happy moving forward until he finds an object. This makes him sad and he turns 90 degrees. If he can move forward he is happy again. If instead there is another object in his path he is shocked / cross ('oh') and turns 180 degrees. Again if the way he clear he is happy again and proceeds. However if there is another object he becomes confused (or his face does) and then turns 90 degrees (away from the initial object and proceeds on his way happy again.




Sunday, 8 February 2015

The Visual-Pi-ser a low cost classroom visualiser

In may last post I described my idea for a low cost visualiser based on the Raspberry Pi kit I was sent as part of the Element 14 Raspberry Pi Educators Road Test. I promised i would add more detail so here it is.



The box for the kit is used as a stand to hold the RPi case. The case in the kit has a mounting point for the camera and the arrangement holds the camera steady over the items to be shown. The main issue for this set up using the box is that the camera has a relatively large minimum focal distance so items at the range as out of focus until the camera is modified.

To modify the camera is a fixed focus unit and the lens is held in place with blobs of glue that can be removed with a craft knife to free up the lens (N.B. the lens can be sensitive to static and can be easily damaged so this needs to be done with care).


This modification allows the lens to be rotated and the items brought into focus. It also has the added advantage of slightly magnifying the subject.

The size of the box supplied is ideal for small physical computing projects but a larger box would give a larger field of view for bigger projects. The camera itself is controlled by using the Raspivid command:

raspivid -t 300000 -rot 90

This rotates the video by 90 degrees (as the camera mount is at 90 degrees to the box) and runs the video for 30000 miliseconds (30 seconds). If a longer or shorter time period is required then the number of milisecond can be changed. If you want to terminate the video session you can do so by using ctrl+c


I have created a guide on how to crate you own Visual-Pi-ser on github.


Wednesday, 21 January 2015

Low cost Raspberry Pi Visualiser

The kit I revived from takeing part in the Element 14 Raspberry Pi Educators Roadtest gave me another project idea.

After delivering CPD at Sheffield Hallam University i was very envious of their AV set up with a visulaiser and PC and RPi all connected to the screen. I can't make all this happen but with the RPi and camera I can make my own.

For work with the Raspberry Pi the box was even the right size to make a stand so i added a lighting solution (cheap torch from the garage and/or a clip on e reader light. Now for under £40 I had a visulaiser set up that i could use in the classroom.


A quick mock up above shows the basic idea but I'll post the full details here once it has been completed along with the python code to control the camera.

Monday, 19 January 2015

Element 14 Educators Road test

Over the holidays I have been experimenting with timelapse photography of crystal formation with the Raspberry Pi. i have been doing this as I have been selected as on of the participants in the Element 14 Raspberry Pi Educators Roadtest. If you haven't come across the Element 14 Roadtests before they are a scheme where kit is sent out to a selected group of volunteers to test and write about. They runs the tests fairly regularly and all you need to do to enter is to write a proposal of what you will do with the kit.

This particular roadtest is of the Raspberry Pi B+ Camera Kit and i wanted to come up with a proposal using the camera functionality in a way I could use the kit with students to teach Computing and Science. My proposal was to work with KS£ and Home educated students on two slightly different projects both based around taking timelapse photography of crystals forming.



We have been playing with crystals at home for a bit with my Home Educated son and this looked like a great project to try with the Raspberry Pi and Pi Camera Module. The Addition of the Wi-Pi adapter and the case with camera mount made it ideal for applications like this where connection to monitor and keyboard would be difficult and a secure mount for the camera essential.

Part of the deal is that you write at least three blog posts and a review of the kit on the Element 14 community website . I am still working on the review and the third blog post but the first two are up already:

Part 1: Introduction to the project

Part 2: Testing



EDIT: (09/03/15)

The Road test is now complete and I have some more blog entries and a review of the kit. I also ended up doing a couple of side projects and wrote a scheme of work for the Time Lapse Crystals project.

Part 3: Home Education Project

Part 4: Summary

Review

Scheme of Work

Side Project 1: Visual-Pi-ser

Side Project 2: Snow Timelapse


The Roadtest was a good opportunity to experiment with the RPi camera module and I enjoyed the chance to try something different. The time lapse photography was a good way to combine science and computing and also produce some beautiful results. I have included one of the example videos here. This one is probably my favourite, It was taken from below the crystals with lighting above as part of the home education project.