Posts in the Physical Computing 1 category

For the calm technology project I wanted to make a key holder that would alert me when I was leaving my house without my keys. Using an IR sensor to detect motion in front of it, and a peizo sensor on the top to detect weight, a small melody would play to remind you to take your keys.

Unfortunately this iteration of the project was a little unpredictable. At times it would would perfectly, and at others I would be able to get the sound to stop. That being said, I was able to capture some footage of the product working! However, all the electronics were outside of the box.


#include "pitches.h"

// analog pin for reading the IR sensor
int IRpin = 1;

const int numReadings = 10;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

int melody[] = {NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
int melody2[] = {NOTE_G3, NOTE_B3, NOTE_C4, NOTE_C4, NOTE_G3, NOTE_A3, NOTE_G3,0};

int noteDurations[] = {
4, 8, 8, 4,4,4,4,4 };

// for pressure sensor
int fsrAnalogPin = 0; // FSR is connected to analog 0
int fsrReading; // the analog reading from the FSR resistor divider

void setup() {
Serial.begin(9600); // start the serial port
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++){ readings[thisReading] = 0; } } void loop(){ fsrReading = analogRead(fsrAnalogPin); //Serial.print("Analog reading = "); //Serial.println(fsrReading); // subtract the last reading: total= total - readings[index]; // read from the sensor: readings[index] = analogRead(IRpin); // add the reading to the total: total= total + readings[index]; // advance to the next position in the array: index = index + 1; // if we're at the end of the array... if (index >= numReadings)
// ...wrap around to the beginning:
index = 0;

// calculate the average:
average = total / numReadings;
// send it to the computer (as ASCII digits)
//Serial.print("average: ");
//Serial.println(average, DEC);

float line = (4800*0.393700787)/(average - 20); //give distance in inches
Serial.print("line: ");
Serial.print(" Analog reading = ");

if (line > 5 && line < 10){ Serial.println("IR YES"); if (fsrReading > 50){
Serial.println("WEIGHT YES");

// int fade = map(line, 0, 30, 0, 255);
// for (int i=0; i< totalPins; i++){ // analogWrite(ledPin[i],fade); // } void playTone(){ // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) { // to calculate the note duration, take one second // divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000/noteDurations[thisNote]; tone(8, melody[thisNote],noteDuration); tone(8, melody2[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); } }

For this project I wanted to create a tool that I could using for a performance I am creating. The concept behind it, is that a dancer is able to control a light source with her breath. The fluctuations through the expanding and contracting of her chest vary the strength of the light. The piece then becomes a metaphor for life, drawing attention to the constant physical act of breathing, and how it keeps us alive.

It was made by using a stretch sensor that detected the amount of movement in the chest while breathing. This data was then sent to another arduino using an xbee. The receiving arduino was connected to a servo, that would adjust a dimmer switch according to the stretch data it was being sent.

The Reciever


Servo myServo;
float timer;
byte incomingByte;
int servoPos [3];

void setup(){

void loop(){
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
// servoPos[0] =;
// servoPos[1] =;
//servoPos[2] =;
// for (int i = 0; i < 3; i = i + 1) { incomingByte =; Serial.println(int(incomingByte)); myServo.write(int(incomingByte)); } }

The Transmitter


int stretchAnalogPin = 0; // stretch is connected to analog 0
int stretchReading; // the analog reading from the stretch resistor divider

int expand = 56;
int contract = 41;

void setup()

void loop()
stretchReading = analogRead(stretchAnalogPin);
byte servoPos = byte(map(stretchReading, contract, expand, 30, 150));

Tami, Oylum, Liz and I worked together on this weeks assignment. We hooked up the IR Sensor to our Arduino, and had it light a series of LEDs. The brightness of the LEDs was determined by the distance of an object in front of the IR sensor. The closer the paper was, the more dim the lights were. The lights gradually became bright as the paper moved further away.

In the code, we averaged out the data coming in from the IR sensor. We then converted the average into inches using a simple equation that we found online. This number was then mapped to a value between 0 and 255, so that we could gradually light the LEDs connected to the PWM pins.

Download Source Code

IR Linearization Project from Oylum Boran on Vimeo.

So I never know how long to steep my tea. It’s a problem, especially in the morning when I’m barely awake to turn on the kettle. The last thing I need to worry about is keeping track of time, so I decided to build a device that keeps track for me.

After I put the tea bag in boiling water, I turn on my timer at wait. At evenly distributed intervals the letters “R-E-A-D-Y” blink, one by one. This lets me know that my tea is still steeping. After 3 minutes (the amount of time needed for that perfect cup) they all blink together, letting me know that my tea is ready.

All I have to do now is sit back, relax, and sip.

Download Source Code Here

So today’s in class assignment was to look at a fellow student’s light organ and build it from our own materials.

Here is Liz’s organ in action:

Luckily her construction was quite similar to my light organ so I could keep the set up of my bread board in tact. The only thing that I needed to do was reprogram my arduino, so that it functioned the same. Unlike mine, hers fades on and off when the buttons are pressed. All I had to do was change some functions to include both the fading in and out. I also simplified the loop function, so that the LED wouldn’t stay on when the button was pressed.

Here is my reengineered light organ to mimic Liz’s:

Download Source Code Here

Overall I really enjoyed delving into the first 6 chapters of Code: The Hidden Language of Computer Hardware and Software. The language and style of writing is probably the most casual of any code or programming book that I have ever read, and I really appreciate this approach in delivering the content. It makes reading, what could be considered dry and boring material, exciting and enjoyable.

In the first chapters explores the nature of binary codes, and demystifies the logic behind Morse code and Braille. For someone who is unclear with how these methods of communication work, it was so interesting to realize how these languages have been developed. I didn’t realize that they were built upon mathematic foundations, powers of 2, combinatorics, etc., but it makes complete sense. Math, however, was never a great friend of mine, so I am interested to look at in from a new perspective while discovering the logic of coding.

Chapters four through six looks at building simple circuits, and the necessary components for connections to function. I appreciated his approach to teaching the reader the symbols of schematics, by slowly introducing important symbols. I will admit that I am still struggling with the mathematic component of measuring voltage, amps, and ohms. I think I need to go back and re-read those parts where he explains in depth how to calculate them.

My attempt a making a quick prototype sketch of a light organ using a speaker. LEDs and push buttons. After programing the buttons to correspond to the specific LEDs, I worked on having the LEDs fade in and out. Then I added different sounds, using the tone library.

I built a little cover for this out of cardboard and reflective shimmery plastic, so the lights could bounce off and create more of a glow. If I work on this further, I will try to space the LEDs out more so that they fill more of the space, rather than being in a single row.

I had a much easier time with the code this week. Being mastering the art of arrays, and they are so useful for this type of programming. Makes the whole project easier to scale and organize. I have also being trying to write more of my own functions, so that most of the code can live outside of the loop.

A note about the video: The sound is a little too soft, as I might have been covering the microphone. But I swear there is sound, you just have to listen closely.

Download the source code here.

Building this was a lot of fun. I really enjoyed figuring out how everything should connect to each other, and it was extremely gratifying to press the buttons and watch the LEDs light up.

The second part of this assignment proved to be more difficult. I spent about a day and a half trying to program Simon Says from scratch. I was able to get the basic functionality, but in the end I could not get it to play right. However my dysfunctional source code is available here for download.

I was able to find an online reference to an existing Simon Says game on an Arduino. I used this as a reference to see what was wrong with my code, and I found that I had generally set it up pretty similarly. But after being terribly frustrated with my broken game, I decided to take this source code and play around with it. I changed all the variable and function names. I also broke it down a bit and created many of my own functions. So with the help of some online code you can download my Simon Says Game here.

And for the video: