Showing posts with label GPIO. Show all posts
Showing posts with label GPIO. 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.

Saturday, 28 March 2015

Getting Physical with Python

This session with my HomeEd group I introduced some physical computing using the CamJam Edu kit .

Last time I blogged about the challenge of teaching a group with my own children (who are not used to a classroom environment). This week I had the additional challenge of my normal child swap falling through so I ended up with 3 of my own children to contend with.

With this in mind my plan was for more independent work with some supporting materials to make it easier for the children to work without my direction all of the time.

I also planned to manage the situation by placing my offspring carefully either side of me in the room so I could switch between the instruction and paying them attention. This worked much better for me to be able to manage the session. Although at one stage it did mean carrying 2 of my children whilst trying to explain things on the board (using my daughter to point out the relevant bits whilst I talked).

I had decided that I did not want to over simplify things for the children by using scratch. We had also been mainly working at the command line so it made sense to progress with this and use nano to create python files to control the components. This also followed the CamJam worksheets so I could use those to provide additional guidance so the children could refer back to the instructions.

As the group is very mixed (5-15) there was a range of experience in the group but most had not used electrical components in a breadboard before. After a quick introduction they were all setting up the simple LED and resistor circuits.

Most of the group managed to get as far as getting the lights lit but it did take some time to get there. The real limiting factor I found with using python with the younger children was the speed they were able to type the code was very slow compared to the older students (as they are still working on their reading skills this is actually quite a hard task).

There was no apparent problem understanding the concepts and adding text to control things, but the amount of text that needed reading and adding to the code was a problem. To make it easier for these younger students (and any students who find reading / typing difficult) it would be useful to reduce the volume of typing that is required to produce a result.

That said nearly all of the children had at least lit the LEDs by the end of the session even if this had involved a bit of help with typing from the adults in the room.








Wednesday, 18 June 2014

Picademy

Two days of CPD is enough to fill most teachers with dread but the Raspberry Pi Foundation is changing all that with its Picademy. Two days of Raspberry Pi training focussed around using the device to it's full potential in the classroom.
 
In April the first Picademy was a great success and the feedback from educators on twitter caught my attention. If you read my first post on this (somewhat neglected) blog you will be aware I had been doing some research into the use of the Raspberry Pi in classrooms. This led me to look for more engaging ways of teaching computing where I could utilise the Pi to it's full extent. I wanted to avoid the replace PowerPoint with Scratch on Raspbery Pi approach and create engaging projects for my students.
 
So where could I go to engage with others and get some inspiration. it was then that #picademy started to appear on twitter. Brilliant, how do I get to go along thought I. Unfortunately the first dates fell over the Easter break and we already had plans. However a series of fortunate events led to a place on the second run. A hastily booked train and hotel later I was off to Cambridge.
 
 
 
We all arrived at Pi Towers not quite knowing what to expect but with high expectations based on what we had seen from the first event.  We were not to be disappointed. After a few housekeeping points we were straight into a day packed full of workshops covering a wide range of activities we could use with students in our classrooms. This included Sonic Pi with Sam Aaron, GPIO with Clive Beale, Minecraft Pi with Craig Richardson and Pi Cam with Ben Nuttall.  There were also sessions on the use of Pi in the classroom using VNC, GitHub and the Raspberry Pi Community. All of the session were led by enthusiastic experts and the content had been backed up with real life experience in classrooms.
 
 
 
These sessions gave a great overview of the varied ways the Pi can be used to engage and enthuse students. I was particularly impressed by the range of ways the Pi can be used to promote the creativity of students.


After a busy day training our minds still buzzing with new information we headed out for the evening meal. This was an amazing opportunity to discuss ideas and network with the other attendees. There were also most of the Pi Towers team on hand to quiz further; how many training providers do you know who are still answering questions at 2130?




The second day started with some inspiring sessions from Eben Upton, Rachel Raynes and  Lance Howarth. A reminder of why the Pi was created and more on creativity.

It was then our turn to get creative in the 'unconference'. The idea being to put to use the inspiration from the first day to practice our skill, create new resources and solve issue we had encountered. In small groups we were able to consolidate what we had seen and further develop our ideas. Some groups worked on teaching resources and others on areas of interest.


 
Our group worked on a few ideas until we settled on the idea of a quiz bear. This initially involved doing unspeakable things to Babbage to embed the Pi inside with an LED smile and buttons in his ears. Fortunately for Babbage, time was short so a plastic cup made a more easily modified host. We developed the idea to create the idea of a modular scheme of work for Technology and Computing. The main idea being to create the basic elements using recipe cards and combine them together. This would get progressively more complicated and open ended (I will post more about this once we have more to share).


After feverishly working in our groups we all came back together to share what we had produced. Each group or individual shared what they had worked on and/or produced. This ranged from personal development consolidating the skills to imaginative products and schemes of work. One of my favourites was the Micheal Jackson Tribute Glove (#MJTG). This was a development of a previous project by one of the group members and produced a dancing animated MJ on screen controlled by the hand of Dan Aldred.



A short video of the end result can be found here.



After all the sharing we gathered for a presentation of the very shiny Raspberry Pi 'Certified Educator badges'. The course was over but we were all still buzzing; in fact my group continued work on the train home, putting together a plan of action to complete our scheme of work.



This was without doubt the best CPD event that I have attended as a teacher but better than that it has opened my eyes to more of the creative possibilities. I have been a firm advocate of not using technology just for the point of using it and had started work to find ways to really utilise the Pi. Picademy has really helped to firm up this approach in my mind and has really shown me how much value the Raspberry Pi has as a tool to engage students and get them being creative in the classroom.


Much has been made of training the next generation of computer scientists, but without engaging curiosity and promoting creativity then we will only be producing a generation of robotic programmers with no love for the subject. Hopefully #picademy and the Raspberry Pi Certified Educators it has produced will be able to help the Foundation to provide that creativity and inspiration.