The assignment here is to pick a space on campus that’s boring and make it interesting. The only requirement is that you use either a Raspberry Pi single-board computer or an Arduino microcontroller to do it. This is another project in our Design Engineering class. Students tackle this project after having learned to program with the Beauty through Processing project. Unfortunately I’ve lost most of the photos from this year.
This idea is based on a cool project that Jaymes Dec at Marymount School showed me where students had turned a staircase into a musical instrument.
Materials and Tools
Raspberry Pi boards. Adafruit is a good source in the US.
Arduino boards, if you want to use these too.
Pi Camera(s) if students will be working with images or video
(Note: new versions of all of the above are constantly being released, check current specs)
Breadboards, jumpers, resistors, diodes – see below for specifics
Sensors for light, sound, movement (PIR), etc
5-12V power supplies
Old computer speakers
Wood scraps and other junk
This project is a chance to transfer programming skills learned while making graphics to physical computing, wherein computers interact with the physical world. The programming will be very different, but the underlying concepts – controlling a program’s flow, evaluating data and acting upon it, being able to figure out how a language works using a reference – are the same. Ideally these concepts sunk in in the previous project. If they didn’t, the teacher will know and can act to shore things up. New skills for this project include advanced circuit design with electronic components, hardware programming, reading and creating schematics, and in most cases, some form of interface design. Some students choose projects that require programming languages other than Processing, like Python.
Note: I’ve put some technical notes at the end of this post that can help with getting set up.
I started the project by sticking a Raspberry Pi, a motion sensor, and a sawed-off computer speaker inside an Oscar the Grouch puppet. When the motion sensor was triggered, the pi was programmed to play different audio files according to the time – a growly voice saying either “Thanks for getting here early”, “You barely made it”, “You’re late!”, and “You should feel shame for being so late”. I mounted Oscar on a table by the door and waited. It got funnier as more kids came in, because we were all waiting for the next victim.
This simple demo showed the most basic kind of interaction – a project reacting to movement. Oscar had changed the space – the entry to the maker lab – and made it more interesting. We talked about what else was possible. A Pi can gather information through a variety of sensors you can attach to it, but also from the internet. It can output information to a screen, but also by turning physical switches on and off – which means it can do almost anything. We looked at some cool examples.
After doing some brainstorming, students came up with the following projects:
- A machine that sprays you with water if you get close enough to it
- An installation that senses your approach, yells at you to “look up!”, snaps your photo and adds it to a gallery
- A hidden unit that makes fart sounds when you walk by
- A Spanish vocabulary video game kiosk
- A teddy bear that insults you more intensely the closer you get
- A sound level sensing traffic light for the library
..And we got to work. Before starting, students needed to learn how to operate the Pi (or in the case of the traffic light, an Arduino, which is easier to use with analog inputs like sound levels). I set up the Pi’s to run headless, which means without a monitor, keyboard, or mouse. Instead, you use a regular computer to connect to the Pi via wifi, and control it using that computer’s screen, keyboard and mouse. Setup notes below. We did a lesson on using the Pi’s GPIO (general purpose input/output) pins with Processing, the language they used in the previous project. In this lesson each student had to get a simple circuit working wherein pressing a button on the breadboard made an led light up. This would be simple to do with a battery, a switch, and an led, but we were aiming higher- students had to program the Pi to sense the button being pressed, then have the Pi turn on the led. Hooking up the button requires one to understand how a pull-down resistor works.
If you have a button attached on one side to 3.3V, the other to a pin, that pin is going to be connected to 3.3V when you press the button, and when you digitalRead() the pin, it will read HIGH (meaning on). The problem is what will digitalRead() come up with when you’re not pressing the button? In this case the pin isn’t connected to anything, which can lead to unpredictable results. So what we do is connect the pin to ground with a resistor. Electric current is like water, it likes to take the easiest path. A resistor is like a spigot, it slows down the flow of current. When you’re not pushing the button, current will flow through the resistor to the ground because it has no other choice and the pin will read LOW (meaning off). When you press the button, you’re giving the current a resistance-free path to the 3.3V pin that it much prefers, and the pin will read HIGH. This circuit is called a pull-down resistor because it “pulls” the pin to LOW when nothing is happening.
Once kids get their minds around this and get this circuit working, they’re ready to start figuring out the circuits they’ll need for their projects. We go over simple circuit diagramming (schematics). Readable circuit diagrams are one of the requirements for the project. Students who want to use a motor (like this making the water spraying project) will need to understand a trickier circuit that uses a MOSFET transistor, as the Pi isn’t powerful enough to drive a motor, just to turn it on and off. The motor needs its own power supply.
Students experienced plenty of setbacks, particularly with the more complex projects. The camera project required the kids to learn Python, as Processing currently doesn’t work with the Pi camera. The Spanish vocabulary video game required more complex programming than the kids expected. The water spraying students had trouble getting a coffee-grinder motor to pull the trigger on a spray bottle, which required more torque than they expected – the lesson being, test early and often. Except for the sprayer, all the student projects worked by the end. We spent about a month on this.
Full writeup with technical notes here: http://lindylabs.org/recipe/change-a-space-with-a-raspberry-pi/