Monday, 7 July 2014

Pi.lab Session 5 - Buzzers and Reed Switches

We were greatly down on numbers in tonight's Computer.lab, mainly due to illness and trips out.  But Patryck and Sara did attend the Pi.lab session where they learnt about creating Python programs to read inputs and using them to control outputs.

The pupils are using a PiFace to interface with external devices such as lights, buzzers and motors to protect the Raspberry Pi from electrical damage due to incorrect wiring and the like and eventually both the boards will be housed in a case to protect them from static and physical damage.  But for now the pupils are working with bare boards to give them a feel for the hardware components they are using.

The session started with a quick overview about what makes an electronic circuit and how a switch can be used to turn the power from a battery on and off, and thus control a light.  Luckily, the pupils seemed to remeber this from Year 8 Science lessons. This was then extended to show how a Rapberry Pi can act as switch in the circuit.  Here are some diagrams used to explain this:

 

This was followed by a brief recap on the Python code to control the onboard LEDs and outputs on the PiFace - this was useful because Sarah had missed the first session on writing programs to control the PiFace.  This can be done in a number of ways, but here is the code that we used:


The pupils then experimented with turning the PiFace lights on and off  for longer and shorter amounts of time and then with sequences of lights.  This was done by simply changing the pfd.leds number and the sleep() value.

After this the pupils attached a small buzzer to Output 1 of the PiFace and ran their original program to flash an LED.  They dicovered that the program not only turns LED 1 on and off, but also Output 1 and, because the buzzer was attached, it beeped like an alarm.  This is because the LEDs are designed to shown which of the eight outputs have been switched on for debugging purposes.


More to follow .....

Pi.lab Session 4 - A Graphical Interlude

In tonight's Pi.lab we had a graphical interlude - instead of writing Python programs to control the PiFace, we did some graphics programming using Python's Turtle module.

Turtle Graphics have their origins in Logo, and educational programming language developed by Seymour Papert at MIT in the 1970's.  The language was originally designed to control a small robot which looked like a turtle moving across the floor.  The turtle held a small pen which it could lift up and down so as it moved the Turtle could draw on paper.

Nowadays actual robot turtles are rarely seen, and have largely been replaced by 'screen' turtles which draw their graphics onscreen rather on paper.   This is the approach the Python Turtle module takes.

P.lab Session 3 - Introdcing the PiFace

Tonight we added a PiFace to our Raspberry Pi computers so that we could control some of it's onboard LED lights using Python.

Pi.lab Session 2 - Programming in Python

In tonight's session we learnt about using loops to program a multiplication table of our choice.

Pi.lab Session 1 - Pi,lab is launched

Tonight we held the first session of Pi.lab which is part of Loreto High School's Computer.lab, an after school ICT and computer club. It was based in the space outside ICT Room 103 and five very enthusiastic pupils attended. They were: Anthony, Sofyan, Patryck, Tristan and Spenser and they couldn't wait to get started.

We began with a quick slideshow about the main hardware parts of a computer system:
  • Input - keyboard, mouse
  • Process - processor or CPU (Central Processing Unit) and memory
  • Storage - hard disk drive, flash memory device
  • Output  - monitor or TV screen
Following this the pupils learnt about the parts of the small Raspberry Pi computer we'll be using in these sessions from a labelled diagram like this:


They also learnt a little about the operating system or OS which is a program which controls the computer system and without which it wouldn't even turn on.  For the Raspberry Pi, the OS is stored on a SD memory card like those used in cameras.  It's called Raspbian and is a version of the open source OS called Linux

After this the pupils were each given a box of computer hardware parts and were then shown how to assemble a system with them based around a Raspberry Pi. It took a little time to get the computer systems all working, mainly because leads were not pushed in completely or the mains power was not switched on. 

The pupils were very pleased when they each got their computer systems to work and displaying the desktop for the first time.  The first thing they did was to play a game written in the Python language - hopefully they soon be writing their own programs and maybe even games.

As the session had gone very well, there was some time at the end to have a first look at the Python programming language.  After experimenting with t a few commands, most of which didn't work, the pupils were shown how to write the traditional first program in computing circles: Hello World.

In the next session we will have a more detailed look at writing programs in Python but for now the pupils' appetite seemed to have been whetted - some of them even wanted to carry on long after the session had finished.  When asked if they'd be coming back to Computer.lab next week the answer was a resounding, "Yeah, definitely!"