Playful Experience Design Through Interactive and Wireless Techniques ------------------------------------//
Design and Technology // MFA // Fall 2008 // Parsons The New School for Design. ------------------------// Instructor: Yury Gitman
Do you often have guests over and wonder what they're doing when you're not looking? Perhaps, they're getting too comfortable and have stopped asking before they open your drawers in the kitchen, bathroom, bedroom, etc. to get what they need?
Hello, How May I Help You? is an adorable and friendly solution for such people like you. Simply place the doll into a drawer of your choice, and turn on the switch before guests arrive. If they snoop into your drawer, the doll will "greet" them with a message when it opens.
Finally, Compy is up and working! Here are some photos of his guts, and his code is below!
Compy's front
I added googly eyes and a pipe cleaner bow-tie to give him a little craft charm.
Compy's Back
His battery pack is attached on the back.
Compy with his Battery Pack removed
The battery pack is attached with velcro. The chip clip which holds Compy onto a laptop is hot glued.
Compy's Guts
I used an Arduino Mini, and had to put that in a little acrylic box from the Container Store separate from another acrylic box containing the speaker and the IR sensor.
Code is below!
PING is a smart trash/recycling bin that tracks your trash activity and reports it online. His aim is to help you develop better recycling habits by collaborating with others.
PING is part of a larger concept that asks the question: "If objects had a voice, what would they say about us and how would we respond?" PING's 'voice' is able to tell users about their trash habits and connects them with other PING users online to allow opportunity for collaboration toward a more sustainable world. PING does this by tracking each time you throw an item in either its waste or recycling compartment and reports this activity online as well as communicating directly with the users through its own illuminating lights. Future iterations of PING will also include a way for the bin to measure weight of the trash, how often the bin gets filled up, and will be able to remind users of trash day so they'll remember to put the trash out. All this data collected will connect to much larger ideas online. For instance, knowing how much paper people recycle can help us calculate how many trees each individual is saving, etc. - allowing each person to feel a bit of accountability and reward for their recycling efforts and help them know that they do in fact play an important part. View a demo video:
PING was created by Katrina Bekessy. Katrina would love to hear any thoughts/opinions/feedback you might have about this project. If you'd like to learn more about it or share your thoughts, please contact Katrina at kmbekessy[at]gmail[dotcom].
So I got the code and circuitry to all work correctly for my "Let's Get It On" Lamp. I am so excited to get it working on the reals.
Yet, i'm still havin some issues with the pants circuitry. Sometimes the fly signal works, others it doesn't.
*Side note: there pants have enough batteries in them to melt through the crotch. This concerns me a bit and it could probably be wired in a more optimal way, with less batteries, but I need a break from this. FYI: Not for actual wearing!
/////-------------------------------------------------CODE-----------------------------------------------------///// /* * BlinkColorFader -- Example of how to select color & brightness * with two pots * * For more info on how to use pots and analog inputs see: * http://www.arduino.cc/en/Tutorial/AnalogInput * * BlinkM connections to Arduino * PWR - -- gnd -- black -- Gnd * PWR + -- +5V -- red -- 5V * I2C d -- SDA -- green -- Analog In 4 * I2C c -- SCK -- blue -- Analog In 5 * * Note: This sketch sends to the I2C "broadcast" address of 0, * so all BlinkMs on the I2C bus will respond. */
#include "Wire.h" #include "BlinkM_funcs.h"
//address for BlinkM #define blinkm_addr 0x00
// INPUT: Potentiometer should be connected to 5V and GND int potPin = 0; // Potentiometer output connected to analog pin 0 #define potPin 0 // analog in pins from zipper signal to control LED fade color: white to red #define ARRAY_SIZE 5 //this is the array size int potNums[ARRAY_SIZE]; //this reads AND stores 10 numbers from the potentiometer input. int pot_val; //potentiometer value from zipper position on jeans
// OUTPUT: Use digital pins 9-11, the Pulse-width Modulation (PWM) pins // LED's cathodes should be connected to digital GND int pPin = 7; //PLAY, conncected to pin8
// Program variables int currentPlace = 0; //this is the total value int placeHolder = 0; //placehoder for each spot in the array int ave = 0; //average pot input numbers (normalize/smooth the input signal)
//SETUP void setup() { BlinkM_beginWithPower(); BlinkM_stopScript(blinkm_addr); // turn off startup script Serial.begin(9600); // ...set up the serial ouput in 0004 format
for (int i = 0; ARRAY_SIZE < 5; i++) { potNums[i] = 0; //fills all values in the array to 0 } pinMode(pPin, OUTPUT); }
// MAIN void loop() { currentPlace -= potNums[placeHolder]; //subtract the last reading from array potNums[placeHolder] = analogRead(potPin); // read the potentiometer value at the input pin currentPlace += potNums[placeHolder]; //add to the array placeHolder++; //add 1 to the placeHolder each loop
if(placeHolder >= ARRAY_SIZE) { placeHolder = 0; //if the placeHolder goes thru the whole array, } //then loop back to the 1st spot in the array
ave = currentPlace/ARRAY_SIZE; //calc the average //Serial.println(ave); // send it to the computer (as ASCII digits)
pot_val = analogRead(potPin); // read the hue pot //Serial.println(pot_val);
//light should fade from white when zipper is up to red when zipper is down BlinkM_fadeToRGB( blinkm_addr, 255, int(pot_val/3.5), int(pot_val/3.5)); // adjust the green and blue to decrease with pot values
if (ave > 600) // Upper third of potentiometer"s range (600) { digitalWrite(pPin, HIGH); //keep digital pin open if zipper is near top }
else if (ave >= 200 && ave <= 500) // Middle third of potentiometer's range (100 - 150) { digitalWrite(pPin, HIGH); //keep digital pin open if zipper is in middle }
else if (ave < 100) // Lowest third of the potentiometer's range (50 - 100)/turn on music here (< 100) { digitalWrite(pPin, LOW); //put digital pin to GROUND if zipper is at bottom }
So, yeah, I figured out what the problems were and finally made the servo work as the way I want! Hooray! When the toy detects me (using sensor), it would turn its head and stay at that position until it detects me again and turns its head.
Servo myservo; //create servo object to control a servo int sensor = 0; // analog pin used to connect the sensor int motorPin=11; int val; // variable to read the value from the analog pin boolean status=0; //status of detecting int counter=0;
Serial.begin(9600); // set up Serial library at 9600 bps pinMode(sensor, INPUT); //pinMode(relay, OUTPUT); pinMode(motorPin, OUTPUT); myservo.setMaximumPulse(2000); myservo.setMinimumPulse(700);
Serial.print("Ready\n"); }//end of setup
int getSensor() { val = analogRead(sensor); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
val=max(val,5); val=min(val,180);
return val; } //end of getSensor
void myRefresh(int delayTime){ for(int i=0; i < delayTime/20; i++){ //delay is the total ms delay we want, 20 is the delay per iteration of the loop Servo::refresh(); delay(20); } }
int move0(){ Serial.print("servo position 0\n"); myservo.write(0); //Servo::refresh(); myRefresh(100); }//end of move0
int move90(){ Serial.print("servo position 90\n"); myservo.write(90); //Servo::refresh(); myRefresh(100); }//end of move90
int move180(){ Serial.print("servo position 180\n"); myservo.write(180); //Servo::refresh(); myRefresh(100); }//end of move180
I defined a function myRefresh() to make sure the servo would be refreshed every 20ms. Then I added 3 moving functions with different angles. The tricky part was that how to make servo stop and turn to reverse direction when the sensor detects someone again. By using 2 variables counter and status, I made servo turn to position 180 when the counter is even and turn to position 0 when it is odd.
In this week, I'll try to put the prototype that I have so far into the body of my plush prototype. The focus of the testing this week will be: - redesign the character for prototyping (make it big enough to put all my electronics) - building/ sewing the plush toy - make the toy's head move! Think about materials, the skeleton, connections... etc.
Here's the code: // Input settings int analogPin = 3; // ir sensor connected to analog pin 3 int val = 0; // variable to store the read value
// Digital pin settings int aOut = 9; // Play pin connected to digital pin 9
// Variables int aVal = 0; // Variables to store the input from the ir sensor
int DEBUG = 1; // Set to 1 to turn on debugging output
int average[100]; // Averaging Code setting byte counter = 0;
void setup() { pinMode(aOut, OUTPUT); // sets the pin as output
if (DEBUG) {
Serial.begin(9600); // Open serial communication for reporting } }
//Main program void loop(){ val = analogRead(analogPin);
//Averaging Code start average[counter] = val; byte c; int total = 0; for(c = 0;c<100;c++){ total += average[c]; } int averaged = total / 100; Serial.println(averaged); counter = (counter + 1) % 100; //Averaging Code. modified from Dave Millis example
if(val < 300){ analogWrite(aOut, 0); delay(1500); analogWrite(aOut, 255); delay(100); } else{ analogWrite(aOut, 255); } if (DEBUG) { // if we want to read the output DEBUG+=1; if(DEBUG>100){ //print every hunderd loops DEBUG = 1; // reset the counter Serial.print(val); }} }
And here is the new win bound recorder which is smaller, more solid, and works as well as the old one. It sounds actually better because I got a bigger speaker for it.
I've scrapped the Winbond, which is both good and bad. The Winbond would have been great for making bird sounds, but the Arduino Mini is so much more compact and easy to work with. It makes sound too, but the computery noises it makes are not very bird-like. In fact, they're just downright annoying.
I'm using the Play Melody code from an Arduino tutorial to get started. I had to add a couple of extra octaves (by halving the frequency of each tone for each octave), and now I'm working on getting the melody to play at the appropriate time.
Right now my code will play a little ditty after 15 seconds if someone is not in front of the IR sensor. I need more parameters, but it's not bad for a proof of concept. Consider is an implementation prototype.
Here is my arudino mini, hooked up to the arduino as a usb connector. Also featured within the mess of wires is an IR sensor, a speaker (bigger than the one I'll end up using, actually), and some fine LEDS to help me figure out what's going on when). The Red LED comes on when the IR is on and reading something is close, and Yellow LED comes on when the IR is reading that nothing is in front of it anymore.
A Close Up
This is just a close up shot of the Arduino Mini, connected to things. I'll be taking it off of the bread board as soon as I'm happy with my code. Until then, it stays, which unfortunately is holding me back from making Birdie look and feel prototypes.
In response to Katrina's great tip about the multiplexer I thought I would pass this little trick on as well.
With only a few simple lines of code you too can use your digital inputs to read analog data. Below is the function. Just copy and paste the code before your void loop(), then call it with digiAnalog(pin). It's pretty easy. Continue reading to see the code:
So here's what I've got going so far...it doesn't look like much right now, but it will make a huge difference once I actually have it all set up in the real trash bin I intend to use. Right now I'm just trying to get everything to work.
I've go the IR sensors detecting which bin (recycling or waste) was used, and the Winbond chip changes tracks and plays back the appropriate sound depending which side was just used. I'm having a bit of a problem with the Windbond chip, though. When it needs to change tracks it won't play back the sound after it has moved forward. It'll only play the sound the next time that side of the bin is used. I can't figure out how to fix it in my code, but I don't think it's a huge problem...just strange. My code is posted at the end of this blog post.
I also have the Arduino counting how many times each side has been used. A green or yellow LED will light up when one side is used more than the other (green = you've recycled more, yellow = you've wasted more).
Alos, I assembled my XBee transceivers. It took FOREVER to solder everything - I even got injured in the process (one of the pins got shoved under my fingernail...awesome.). I haven't set them up to work yet...but that's going to happen in the next day or two. For now, all data from the bin can be seen through the serial reader in Arduino. I've posted a screenshot of it below.
Lastly, I started playing with some big FSR's to use as a rough scale/weight measurement for now. Next task for me is to figure how I'm going to normalize their numbers in my code...I have no clue how I'm going to do that...
Here's some pics:
The inside of my 'bin'...not pretty, but semi-functional at least!
Had to show off my awesome soldering job...male and female header pins all in a row, just so I can mount a silly XBee on it.
Screen shot of Arduino serial reader showing my bin data...with some lovely notes included in red.
-getting my Windbond chip to change tracks and play back the sound right after -normalizing my FSR inputs to numbers that actually mean something -keeping the stupid IR sensors consistent. Everytime I turn them on they start with different readings than before
Next things I need to do:
-include FSR's and photoresistor (for lid of bin) with rest of my circuit using a multiplexer -get XBee's to send bin data to computer wirelessly -build working circuit into actual trashbin -refine code to make readings more accurate
Am in way over my head? Yes, yes I am...
Here's my long Arduino code thus far. I'm sure it could be written much more succinctly/efficiently...
Prototype 005 Materials: PIC16F88, breadboard, servo, pot Notes: - The servo could keep turning left and right, but I couldn’t control its speed and directions. - I found that Arduino has a servo library that is easy to use for controlling servos. So I decided to switch to Arduino board.
Prototype 006 Materials: Arduino, servo, breadboard, IR sensor Notes: - In the very beginning, the range of IR sensor was too small. Thus the servo only moved when I almost touched the sensor. Here I scaled the value of IR sensor from 0-1023 to 0-179.
- The servo had a problem of drawing too much current.
- So I did iteration by separating power supply for the servo, but joined the grounds of the two power supplies. I also added decoupling capacitors to stabilize my voltage regulator.
- Here is the code: -------------------------------------------------------------------------------------------------------- #include <Servo.h>
Servo myservo; //create servo object to control a servo int sensor = 0; // analog pin used to connect the sensor int motorPin=11; int val; // variable to read the value from the analog pin
Serial.begin(9600); // set up Serial library at 9600 bps pinMode(sensor, INPUT); //pinMode(relay, OUTPUT); pinMode(motorPin, OUTPUT); myservo.setMaximumPulse(2000); myservo.setMinimumPulse(700);
Serial.print("Ready\n"); }
int getSensor() { val = analogRead(sensor); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
void loop() { /* val=getSensor(); if (val<140){ val=180; myservo.write(val); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there }//end of if
while(getSensor()>30){ myservo.write(getSensor()); Serial.println(getSensor()); delay(15); }//end of while */ myservo.write(getSensor()); Serial.println(getSensor()); delay(15);
//moveFoward(); //moveBackward(); Servo::refresh(); } ------------------------------------------------------------------------------------------------- - I tried to pause the servo after every time it turns by expanding the delay time of myservo.write(). However, its movement became unpredictable. Then I tried moveFoward() and moveBackward() above, but they didn’t work well either. - Another problem I have is the click sound of servo. I was wondering if extreme turning angles like 179 or 180 caused those noise.
I set three functions for different range of distance as fallowing: 1.about 50-80cm: Play 2.about 15-50cm: Play and fwd 3.about under 15cm: Play and change volume
Here's the video where I use three leds to test if the code works first.
The left led is Play, the middle one is Fwd, and the right one is Vol. So, it works fine with pin high and low/led on and off. And here is the code.Download ir_recorder.rtf
Then I put the connectors to the recorder. Here is what happen on level 1 and 2.
Sweet, I still need to mess with the code a bit. Got me thinking about integrating it into a chair that will say things like 'DON'T SIT ON ME' or 'WHY AREN'T YOU SITTING' or 'TAKE A SEAT.' Making inanimate objects communicate. Maybe an egg slicer that says 'NOOOO DON'T KILL ME!' when the slicer gets through the egg.
I tried Matt's code and it worked well, but what you see in the video is my less sophisticated code at work which you can see here:
int irPin = 3; // IR sensor is read from pin 3 int irVal = 0; // hold the values read from the IR sensor
int orngPin = 9; // Orange LED, connected to digital pin 9 int bluPin = 10; // Blue LED, connected to digital pin 10 int grnPin = 11; // Green LED, connected to digital pin 11
void setup() { pinMode(orngPin, OUTPUT); // sets the pins as output pinMode(bluPin, OUTPUT); pinMode(grnPin, OUTPUT); Serial.begin(9600); //see what the heck my IR sensor is reading }
// Main program void loop() { irVal = analogRead(irPin);
if (irVal>=200) //when you're closest to the sensor { digitalWrite(grnPin, HIGH); digitalWrite(bluPin, LOW); digitalWrite(orngPin, LOW); } else if (irVal>= 75 && irVal<=200) //middle range of sensor { digitalWrite(grnPin, LOW); digitalWrite(bluPin, HIGH); digitalWrite(orngPin, LOW); } else if (irVal<75) //when you're the furthest away { digitalWrite(grnPin, LOW); digitalWrite(bluPin, LOW); digitalWrite(orngPin, HIGH); } Serial.print(irVal); Serial.println(); }
I didn't use the average code, actually I didn't know there's an average code until Yury mentioned about it. Somehow my LEDs wouldn't flicker a lot. So here is my code. It is quite simple. Basically I just change the on and off status of each LED in different ranges.
/* *New Arduino hooked-up to 3 different Super-Bright LEDs. *Program the 3 LEDs to turn on/off individually depending on distance of hand. *Tzumei M. Hsiao */
// Analog pin settings int irIn = 3; // the IR sensor connected to the analog pin 3
// Digital pin settings int redLED = 9; // LEDs connected to digital pins 9, 10 and 11 int blueLED = 10; // (Connect cathodes to digital ground) int greenLED = 11;
// Values int irVal = 0; // the variable to store the input from the IR sensor int redVal = 0; // the variable to store the value of red LED int greenVal = 0; // the variable to store the value of green LED int blueVal = 0; // the variable to store the value of blue LED
// Variables for comparing values between loops int i = 0; // Loop counter int wait = (1000); // Delay between most recent pot adjustment and output
int sens = 3; // Sensitivity threshold, to prevent small changes in // IR sensor values from triggering false reporting // FLAGS int PRINT = 1; // Set to 1 to output values
void setup() { pinMode(redLED, OUTPUT); // sets the digital pins as output pinMode(blueLED, OUTPUT); pinMode(greenLED, OUTPUT); Serial.begin(9600); // Open serial communication for reporting }
void loop() { i += 1; // Count loop
irVal = analogRead(irIn); // read input pins, convert to 0-255 scale if (irVal < 300)//if (irVal<341) { redVal= 255; greenVal= 1; blueVal= 1; }//end of if else if (irVal< 600)//else if (irVal< 682) { redVal= 1; greenVal= 1; blueVal= 255; }//end of else if else { redVal= 1; greenVal= 255; blueVal= 1; }//end of else
analogWrite(redLED, redVal); // Send the new value to LEDs analogWrite(blueLED, blueVal); analogWrite(greenLED, greenVal);
if (i % wait == 0) // If enough time has passed... { if ( irVal > sens ) // If old and new values differ // above sensitivity threshold { if (PRINT) // ...and if the PRINT flag is set... { Serial.print("The value of IR sensor: "); // ...then print the values. Serial.print(irVal);
PRINT = 0; } } else { PRINT = 1; // Re-set the flag }
I had some wacky issues connecting my IR sensor, but found a useful diagram, also including here:
I ended up adapting Matt's code also. My original code made the lights flicker a lot, but Matt averaged out the IR signal quite effectively. Kudos to you, sir. Matt's code is also after the jump.
What a disaster! I've ruined one an IR sensor, and only just about managed to get this second one in action. I haven't changed my code (yet), so I'm still using the code from the Arduino site. The code can been seen below.
Here are some fine photos of the thing in action. The Color Mixer
This is what my color mixer looks like from the top. The black rectangle on the right is my IR sensor. I'd like to make a nicer case for this soon.
The Innards
Here are the innards of my color mixer. It's kind of a mess.
The Disaster
Through the simultaneous use of solder, wrapping wire, and hot glue, I finally got this working, for the most part. I do not recommend this approach. Jumper wires are definitely the way to go.
Here's a short video of a color mixer I made using a tri-color led. I used the color mixer code from the Arduino site. To see the code, click the link at the bottom of the post.
This is the inside of the mixer. That's the arduino on the left! Note I finally got that tri-color led working. Yesss! Turns out the short pin does go to power....good to know.
Materials: Arduino, jumper wires, potentiometer, 9v battery, LEDs, resistors, DC power plug, tracing paper, scotch tape, fiberfill
Here is my code: /* *Color Mixer *Tzumei M. Hsiao *I modified the code from "Coffee-cup" color mixer on Arduino.cc */
// Analog pin settings int potIn = 3; // the potentiometer connected to the analog pin 3
// Digital pin settings int redLED = 9; // LEDs connected to digital pins 9, 10 and 11 int blueLED = 10; // (Connect cathodes to digital ground) int greenLED = 11;
// Values int potVal = 0; // the variable to store the input from the potentiometer int redVal = 0; // the variable to store the value of red LED int greenVal = 0; // the variable to store the value of green LED int blueVal = 0; // the variable to store the value of blue LED
// Variables for comparing values between loops int i = 0; // Loop counter int wait = (1000); // Delay between most recent pot adjustment and output
int sens = 3; // Sensitivity threshold, to prevent small changes in // pot values from triggering false reporting // FLAGS int PRINT = 1; // Set to 1 to output values
void setup() { pinMode(redLED, OUTPUT); // sets the digital pins as output pinMode(blueLED, OUTPUT); pinMode(greenLED, OUTPUT); Serial.begin(9600); // Open serial communication for reporting }
if (potVal< 341) { potVal= (potVal* 3) / 4; //normalize to 0-255 redVal= 255-potVal; greenVal= potVal; blueVal= 1; //blue off } //end of if else if (potVal< 682) { potVal= ((potVal-341)*3) / 4; //normalize to 0-255 redVal= 1; //red off greenVal= 255-potVal; blueVal= potVal; } //end of else if else { potVal= ((potVal-682)*3)/ 4; //normalize to 0-255 redVal= potVal; greenVal= 1; //green off blueVal= 255-potVal; } //end of else
analogWrite(redLED, redVal); // Send the new value to LEDs analogWrite(blueLED, blueVal); analogWrite(greenLED, greenVal);
if (i % wait == 0) // If enough time has passed... { if ( potVal > sens ) // If old and new values differ // above sensitivity threshold { if (PRINT) // ...and if the PRINT flag is set... { Serial.print("The value of potentiometer: "); // ...then print the values. Serial.print(potVal);
PRINT = 0; } } else { PRINT = 1; // Re-set the flag }
Recent Comments