Posts in the Courses 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.