Archive for the ‘Physical Computing’ Category

Personified chair

Thursday, December 23rd, 2010

Our goal for this project was to make a chair that would remind the user to take breaks when working. By giving the chair a voice, it would interrupt the user once in a while with some funny line that would change based on how long the user had been sitting in the chair. So that was our initial idea.

Then the hunt for the right chair personality began. That meant finding the right physical chair, the right voice, the right script, the right logic for when to say what, and the right story to frame the chair personality. We prototyped and tested on our classmates, we tried and we failed. But in the end we had the chair (almost) right where we wanted it:

The right physical chair

…ended up being the chair I bought in a thrift store in Williamsburg when I just moved here. I donated it to the project, and all we needed to do was to add a pillow to put a switch inside that would sense when the user is present.

The right voice

…we found this amazing voice talent on YouTube, and he was just happy to make the chair come alive with his voice. But he did need a script…

The right script


We struggled a bit with deciding whether or not the chair would be creepy and perverted, or just plain grumpy. We ended up using the more creepy version, because we felt that personality would work well with our goal of trying to get the user to get away from the chair without necessarily having to be explicit about our motivations.

The right logic
We grouped the quotes into different categories to make sure the character would evolve in the right way over time – with some random lines squeezed in between the more rigid logic.

GREETING

  • 1_1 Hiya *
  • 1_2 Hey there
  • 1_3 Hey there creamy ham strings.
  • 1_4 Well looks like the good lord just sent me a gift from above.
  • 1_5 There ya are. *
  • 1_6 Holy molly, it must be my birthday.

30 MINUTES

  • 2_1 You feel nice.
  • 2_2 Ahhhh, that’s the spot.
  • 2_3 I’m starting to get warm.
  • 2_4 You know if you get sweaty and like to take your shirt off that’d be just fine.

60 MINUTES

  • 3_1 You feel so right.
  • 3_2 I think you’re startin’ to grow on me.
  • 3_3 You feel soft

120 MINUTES

  • 4_1 I’m countin’ every second we’re together.
  • 4_2 You’re working hard, really haaard
  • 4_3 I can’t think of a better way to spend our evenings.

180 MINUTES

  • 5_1 Drop your cock and grab your socks. It’s time to get up!
  • 5_2 You gonna razz my berries if you stay here much longer.
  • 5_3 Why don’t you stretch out those creamy ham strings?

240 MINUTES

  • 6_1 Oh you startin to piss me off you piggly son of a bitch.
  • 6_2 You get off me you pervert.

RANDOM NOISES INBETWEEN

  • x_1 [raspy cough]
  • x_2 Hmmmphhfft. *
  • x_3 Hmm. *
  • x_4 Hmmmmmmmmmm.
  • x_5 Mmmmmmm.
  • x_6 [Ach!] *
  • x_7 [Sneeze]
  • x_8 Dag-gummit.
  • x_9 I think I’ve got a little to much stuffin’, why don’t you fish in there and dig some out?
  • x_10 I know what boys like [song]
  • x_11 YMCA [song]
  • x_12 Snoring

WHEN USER GETS UP

  • left_1 Where ya going?
  • left_2 I hope you’re coming back soon.
  • left_3 Come on over here.
  • left_4 Awww don’t be a wet rag. Come on back. Wonderin’ if you’re ever gonna come back…
  • left_5 It’s getting lonely.
  • left_6 Where are ya?
  • left_7 You’re a lazy fatass son of a bitch.
  • left_8 Wondering if you’re ever gonna come back?

So we had a plan for the logic, but when we started coding and testing it, our chair got into silent mode every time the user had been sitting in the chair for a certain amount of time. Although the pattern was clear, it took us a long time to figure out why our chair got all shy after about 35 seconds of rambling. The last night before our final presentation we kept staring at the screen below, tested different time periods, timed when the chair got quiet, and got all confused.

After a long time of troubleshooting (scanning both this and this site for answers), we got this vague idea about it maybe being a RAM issue in Arduino. The problem was that we had no time to solve it at that point. This meant that when we presented our chair, the whole act was condensed into 35 seconds of chair fun. Even though we wanted it to be functional for a little more than that, the 35 second show worked well in the presentation format as long as we could explain our intentions to the audience. Our 35 seconds chair show was based on this code.

The right story
At 3AM the night before the presentation, our group decided that the story that would bring our chair to life would be narrated through me, the chair owner, in a video format. With no acting experience, no make-up, no energy, no real script, and close to no sleep the last couple of nights, I was placed in the spotlight to explain my relationship to this obnoxious chair. The only thing I actually “had”, was a well-developed fear of the video camera. All things considered, I think it turned out quite well, due to Benjamin’s skills within interviewing chair owners, filming, and editing. So here’s the story about me and my chair, Rufus:

Story of Rufus from Benjamin Gadbaw on Vimeo.

The presentation
I think the presentation went well – we got some good feedback about how we could possibly develop the chair further. Most of the feedback was touching upon ideas we had early in the process, but had to abandon due to limited time and/or technical skills. Either way, I’m happy with the project, and am also looking forward to getting Rufus home again after the Winter Break.

Lab #9 Serial

Wednesday, November 17th, 2010

So, this was the most interesting thing we did in this lab – letting Arduino and Processing work together in perfect harmony.

But it all started when we…

CONNECTED A POTENTIOMETER
We attached the potentiometer’s outer red and black wires to power and ground, and connected the middle wire from the potentiometer to the Analog input pin 0 on your Arduino board.

SENDING SERIAL OUTPUT
Used the following Arduino program to send serial output of the values as bytes out to the computer:

int analogPin = 0;
int analogValue = 0;

void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
analogValue = analogValue / 4;
Serial.print(analogValue, BYTE);
// pause for 10 milliseconds:
delay(10);
}

CHECKED SERIAL OUTPUT
We opened the Arduino serial monitor and using the default settings of parsing at 9600 baud, we played with the potentiometer to see the output (or scrolling) of ASCII values.

Turning the potentiometer at different speeds affected the output (numerals, versus capital and lowercase letters). Click here to see it in action.

VERIFYING SERIAL PORT
We loaded a Sensor Graphing Sketch program to Processing. But first, before putting it into action, we verified the correct serial port.

MAKING A GRAPH
After verifying, we played the graphing program in Processing. This program basically demonstrated how serial output can be used to drive communication between different software components (in this case Arduino and Processing). And here’s the result:

Lab #8 Motors

Wednesday, November 17th, 2010


Parts we used:
H-bridge, diode (brownish red colored little fellow), TIP-120 transistor (three legged black square), small DC motor, 10 µF capacitor (the black cylinder). We also used the breadboard, hook up wire, Arduino, potentiometer, switch, 1K Ohm resistor, 10K Ohm, resistors (or similar), wire stripper, multimeter.

HOOKING UP ARDUINO BOARD, ADDING POTENTIOMETER
Hooked up the Arduino to the breadboard, and then we added a potentiometer with the middle “output” wire connected to analog pin 0.

ADDING MOTOR
We soldered wires to the motor, and connected the motor wires to power and to the center collector pin of the TIP120 transistor. Then we connected the output end of an LED to the same center collector pin of the transistor. Then we added a diode with the input end of the attached to the right-side emitter pin of the transistor. This diode will prevent a spinning motor’s “blowback” current from shorting out the circuit.

We connected a 1K ohm resistor to the left-side base pin of the TIP120 transistor. We wired the other end of that resistor to Arduino digital pin 9. To reduce noise in the circuit, we put a 10µF capacitor between the power and ground rails of the breadboard. The circuit was completed by connecting the right-side emitter pin of the TIP120 to ground. This is what it looked like:

UPLOADED CODE
Uploaded the following code to translate the analog input into digital output that moves the motor.

int motorPin = 9; // motor connected to digital pin 9
int analogPin = 0; // potentiometer connected to analog pin 0
int val = 0; // variable to store the read value
void setup()
{
pinMode(motorPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(motorPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}

LOOK, it works, and we made a 6 seconds video to prove it!

ADDED A SWITCH
Removed all components except the motor and the wires connecting power between Arduino and the breadboard, and then hooked up a regular switch (SPST) to the breadboard.

ADDED AN H-BRIDGE
By adding a bunch of wires to different places on the breadboard all of a sudden an H-bridge was hooked up. Amazing. This is what such an H-bridge looks like all wired up:

This H-bridge combined with the code below was supposed to let us control the motor to go in different directions depending on the switch being in ON or OFF position. We didn’t actually make it happen, and we are not sure why – even after troubleshooting for a while. However, we are pretty sure the answer is hidden somewhere within the delicious spaghetti of wires surrounding the H-bridge.

const int switchPin = 2; // switch input
const int motor1Pin = 3; // H-bridge leg 1 (pin 3, 1A)
const int motor2Pin = 7; // H-bridge leg 2 (pin 7, 2A)
const int enablePin = 9; // H-bridge enable pin
const int ledPin = 13; // LED
void setup() {
// set the switch as an input:
pinMode(switchPin, INPUT);
// set all the other pins you’re using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(ledPin, OUTPUT);
// set enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 3, 100);
}
void loop() {
// if the switch is high, motor will turn on one direction:
if (digitalRead(switchPin) == HIGH) {
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
}
// if the switch is low, motor will turn in the other direction:
else {
digitalWrite(motor1Pin, HIGH); // set leg 1 of the H-bridge high
digitalWrite(motor2Pin, LOW); // set leg 2 of the H-bridge low
}
}
/*
blinks an LED
*/
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}

Lab #7 Processing revisited

Saturday, November 13th, 2010

These people are freaked out. Why? Unless you click on the picture, you will never find out! In addition to these freaked out people, I have also made bouncing squares, blinking squares, squares that change color and snow men. It’s all here:

SquareLights
RaceTrack
ColorSquares
Bounce
Snow man
Freaked out creatures

Spelling Magic

Sunday, November 7th, 2010

We needed to find a problem in the world, and then fix it through the use of physical computing. Our problem is that we simply hate spelling mistakes. To make people spell correctly you need to get to them early. We made a simple game for kids to play with, that will give them immediate feedback on whether they are spelling right or wrong. In the short video below we are spelling the word ART. This is a prototype, which means some other 3 letter words can be spelled, but unfortunately not all words. The game is limited because we have not made enough contacts in each letter space for all letters of the alphabet to be used.

THIS IS HOW IT WORKS

THIS IS OUR LITTLE SECRET

AND THIS IS THE MIGHTY GAME BRAIN
…or the code behind it if you like. Except that in this code example, the user has to spell the word CAT instead. I guess CAT is a bit more kid-friendly than the word ART. Anyway. Game brain coming up:

//PIN FOR THE LED LIGHTS CONNECTED TO PLACES ON BLOCK TRAY

#define LED 10 // the pin for the LED for first letter block
#define LED2 11 // the pin for the LED for 2nd letter block
#define LED3 12 // the pin for the LED for 3rd letter block

//THE CONTACT SPOTS ON THE BLOCK TRAY

#define P1X 2 // the input pin where the contact for block 1 is connected
#define P1Y 3 // the input pin where the contact for block 1 is connected
#define P2X 4 // the input pin where the contact for block 2 is connected
#define P2Y 5 // the input pin where the contact for block 2 is connected
#define P3X 6 // the input pin where the contact for block 3 is connected
#define P3Y 7// the input pin where the contact for block 3 is connected

//STORING STATE OF THE INPUT PINS FROM LETTER BLOCKS

int placeX = 0; // val will be used to store the state of the input pin
int placeY = 0; // val will be used to store the state of the input pin
int place2X = 0; // val will be used to store the state of the input pin
int place2Y = 0; // val will be used to store the state of the input pin
int place3X = 0; // val will be used to store the state of the input pin
int place3Y = 0; // val will be used to store the state of the input pin

//THE WORD THE USER MUST SPELL

String theword = “CAT”; // using a constant String

void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(LED2, OUTPUT); // tell Arduino LED is an output
pinMode(LED3, OUTPUT); // tell Arduino LED is an output
pinMode(P1X, INPUT); // and contact is an input
pinMode(P1Y, INPUT); // and contact is an input
pinMode(P2X, INPUT); // and contact is an input
pinMode(P2Y, INPUT); // and contact is an input
pinMode(P3X, INPUT); // and contact is an input
pinMode(P3Y, INPUT); // and contact is an input
}

void loop(){
//READING EACH OF THE LETTERS IN THE WORD
int letter1 = theword.charAt(0);
int letter2 = theword.charAt(1);
int letter3 = theword.charAt(2);

//READING EACH OF THE LETTER BLOCKS
placeX = digitalRead(P1X); // read input value and store it
placeY = digitalRead(P1Y); // read input value and store it
place2X = digitalRead(P2X); // read input value and store it
place2Y = digitalRead(P2Y); // read input value and store it
place3X = digitalRead(P3X); // read input value and store it
place3Y = digitalRead(P3Y); // read input value and store it

//CHECKING LETTERPLACE 1
// CHECK whether input from the block is HIGH-HIGH (A)
if (placeX == HIGH && placeY == HIGH) {
if(letter1 == ‘A’) {
digitalWrite(LED, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is HIGH-LOW (T)
else if (placeX == HIGH && placeY == LOW) {
if(letter1 == ‘T’) {
digitalWrite(LED, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is LOW-HIGH (C or R or F)
// Made the same pattern underneath the C, R and F letter blocks
// The child can then play with different words that can be spelled with _AT
else if (placeX == LOW && placeY == HIGH) {
if(letter1 == ‘C’) {
digitalWrite(LED, HIGH); // turn LED ON
}
}

//CHECKING LETTERPLACE 2
// CHECK whether input from the block is HIGH-HIGH (A)
if (place2X == HIGH && place2Y == HIGH) {
if(letter2 == ‘A’) {
digitalWrite(LED2, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is HIGH-LOW (T)
else if (place2X == HIGH && place2Y == LOW) {
if(letter2 == ‘T’) {
digitalWrite(LED2, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is LOW-HIGH (C or R or F)
else if (place2X == LOW && place2Y == HIGH) {
if(letter2 == ‘C’) {
digitalWrite(LED2, HIGH); // turn LED ON
}
}

//CHECKING LETTERPLACE 3
// CHECK whether input from the block is HIGH-HIGH (A)
if (place3X == HIGH && place3Y == HIGH) {
if(letter3 == ‘A’) {
digitalWrite(LED3, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is HIGH-LOW (T)
else if (place3X == HIGH && place3Y == LOW) {
if(letter3 == ‘T’) {
digitalWrite(LED3, HIGH); // turn LED ON
}
}

// CHECK whether input from the block is LOW-HIGH (C or R or F)
else if (place3X == LOW && place3Y == HIGH) {
if(letter3 == ‘C’) {
digitalWrite(LED3, HIGH); // turn LED ON
}
}

//CHECKING IF BLOCK IS REMOVED

if (placeX == LOW && placeY == LOW) {
digitalWrite(LED, LOW); // turns the LED off*/
}
if (place2X == LOW && place2Y == LOW) {
digitalWrite(LED2, LOW); // turns the LED off*/
}
if (place3X == LOW && place3Y == LOW) {
digitalWrite(LED3, LOW); // turns the LED off*/
}
}

Lab #6 Analog output

Wednesday, October 20th, 2010

Friday afternoon. I was so ready to go home from the studio, considering that I spent the night before singing karaoke with some of my classmates until 4AM. However, when I realized that four eager students were about to start this week’s lab, I figured my hangover would just have to be put on hold while joining them. This lab is about music in the same way karaoke is about music. It’s “music”. So stay with me while I redefine the concept of music. Or just let me ramble on without any readers.


Some of my very eager classmates in the process of inventing a musical instrument!

Parts we used: Arduino, potentiometer wired for breadboard connections, servo motor, variable resistor(s) of your own choosing, fixed resistors as needed to create voltage divider circuits, small speaker (Radio Shack model 273-092 or similar), wire stripper, multimeter, breadboard, hook up wire.

SERVO MOTOR

We connected the power from Arduino to the breadboard, and hooked up the servo motor and potentiometer to it like this:

This was the code we used to control the servo with the potentiometer:

// Controlling a servo position using a potentiometer (variable resistor)

#include

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
val = analogRead(potpin); // 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)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

By changing the mapping from this:

val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 179)

to this:

val = map(val, 0, 1023, 0, 90); // scale it to use it with the servo (value between 0 and 90)

we’re able to make the potentiometer only control movement between 0 and 90 degrees instead of 180 degrees for the servo motor.

SPEAKER SETUP AND NOISE

We removed the servo motor, and connected the speaker to ground and to digital pin 8. Adding a 1K resistor kept us from overdriving the speaker. We downloaded the Tone library and installed it in our ~/Documents/Arduino/libraries folder, restarted the program, and then loaded this code onto our Arduino:

#include
Tone mytone; // declare a tone name

void setup() {
// initialize the tone
mytone.begin(8);
}

void loop() {
// read the analog input
int inVar = analogRead(0);
// map the input to a frequency range between 200 and 2000 Hz
int note = map(inVar, 0, 1023, 200, 2000);
// play the note
mytone.play(note);
}

Now we were able to control a tone (or noise, if you like) with the potentiometer. This is how it sounds. And looks. Yeah, it’s a video. 10 seconds of your precious time. I’m not sure it’s worth it, though. Just saying.

CREATE SOMETHING UNIQUE

By using a force sensor we can change the tone that the speaker is playing just by pressing the sensor in different ways. We combined code from our Analog input lab with the code we just used to get this to work:

#include
Tone mytone; // declare a tone name
int forcePin = 3; // force sensor connected to analog pin 3

void setup() {
mytone.begin(8); // initialize the tone
}

void loop() {
int inVar = analogRead(forcePin); // read forcePin
int note = map(inVar, 1, 1023, 200, 2000);
// map the input to a frequency range between 200 and 2000 Hz
mytone.play(note); // play the note
}

If you look at this unique invention and define it as a musical instrument, then that’s good. To be completely honest with you — I’d rather go play my organ.

Lab #5 Programming with Processing

Wednesday, October 13th, 2010

Time to learn programming in a new language. Why? Because you can do cool stuff. Like copying art work that famous artists have made:


This is my copy of an artwork called Growth and Youth, and is originally made by Josef Albers.

But before I could make that art work, I had to learn some basic stuff about creating shapes and playing with colors.

BASIC STRUCTURE

void setup()
{
size(640, 480); //Setting width, height
background(0); //Background color black
println(“Oh, what a JOYFUL message this is!”); //Printing message
}

FIRST SKETCH

Learning how to draw different shapes.

void setup()
{
size(400, 400); //Setting width, height
background(#ffffff); //Background color white
}

void draw ()
{
point(30,30); // x, y
line(30,50, 80,50); //x1, y1, x2, y2
triangle(30,70, 80,70, 55,100); //x1, y1, x2, y2, x3, y3
quad(30,120, 80,120, 80,150, 30,150); //x1, y1, x2, y2, x3, y3, x4, y4
rect(30,160, 30,60); //x1, y1, width, height
ellipse(50,280, 40,80); // x, y, width, height
}

FULL COLOR

Adding color to the equation.

void setup()
{
size(400, 400); //Setting width, height
background(#e8e8e8); //Background color
}

void draw ()
{
//POINT
stroke(#000000);
point(30,30); // x, y

//LINE
stroke(#000000);
line(30,50, 80,50); //x1, y1, x2, y2

//TRIANGLE
stroke(#00a666);
fill(#bdefdc);
triangle(30,70, 80,70, 55,100); //x1, y1, x2, y2, x3, y3

//QUAD
stroke(#a60046);
fill(#f5cfdf);
quad(30,120, 80,120, 80,150, 30,150); //x1, y1, x2, y2, x3, y3, x4, y4

//RECT
stroke(#fc9c06);
fill(#f8e7cb);
rect(30,160, 30,60); //x1, y1, width, height

//ELLIPSE
stroke(#2e06fc);
fill(#dfd9fc);
ellipse(50,280, 40,80); // x, y, width, height
}

Now I was ready to copy the great artists (mainly the great artists that play with basic shapes, though):

ALBERS

// Growth and Youth by Josef Albers

void setup()
{
size(480, 480); //Setting width, height
background(#9badaf); //Background color gray
}

void draw ()
{
//1st rect
stroke(#c6d7de);
fill(#d4a00d);
rect(23,23, 433,433); //x1, y1, width, height

//2nd rect
noStroke(); //No stroke for this and the next rectangles
fill(#ddb834);
rect(68,88, 343,343); //x1, y1, width, height

//3rd rect
fill(#dec83e);
rect(112,142, 257,257); //x1, y1, width, height

//4th rect
fill(#d7d05e);
rect(155,195, 170,170); //x1, y1, width, height
}

CREATING A PAINT PROGRAM

Time to make a basic paint program. In my final program you can do some fabulous painting with my specialized yellow dot paintbrush, like this:

You can also clear the screen by clicking the white button. Try my paint program! This is how I started out:

void setup()
{
size(480, 600); //Setting width, height
background(#9badaf); //Background color
}

void draw()
{
//MAIN CIRCLES WHERE MOUSE POINTER IS

//Large circle
fill(#d4a00d); //Fill color
noStroke();
ellipse(mouseX,mouseY,50,50);

//Smaller circle
fill(#ddb834);
ellipse(mouseX,mouseY,35,35);

//Smallest circle
fill(#dec83e);
ellipse(mouseX,mouseY,15,15);

//SMALL DOTS OUTSIDE OF MOUSE POINTER

fill(#dec83e);
ellipse(mouseX+30,mouseY+30, 15,15);

fill(#dec83e);
ellipse(mouseX-30,mouseY-30, 10,10);

fill(#dec83e);
ellipse(mouseX-50,mouseY, 5,5);

fill(#dec83e);
ellipse(mouseX,mouseY-50, 10,10);

fill(#dec83e);
ellipse(mouseX+30,mouseY-20, 15,15);

fill(#dec83e);
ellipse(mouseX+50,mouseY, 5,5);
}

PAINTING WITHIN A CERTAIN AREA

void setup()
{
size(480, 600); //Setting width, height
background(#9badaf); //Background color
stroke(#ffffff);
noFill();
rect(30,30, 300,300); //Area to draw in
}

void draw()
{
//CHECKING IF MOUSE PRESSED AND INSIDE RIGHT AREA
if ((mousePressed == true) && (mouseX>82) && (mouseX<278) && (mouseY>85) && (mouseY<293)) {

//MAIN CIRCLES WHERE MOUSE POINTER IS

//Large circle
fill(#d4a00d); //Fill color
noStroke();
ellipse(mouseX,mouseY,50,50);

//Smaller circle
fill(#ddb834);
ellipse(mouseX,mouseY,35,35);

//Smallest circle
fill(#dec83e);
ellipse(mouseX,mouseY,15,15);

//SMALL DOTS OUTSIDE OF MOUSE POINTER

fill(#dec83e);
ellipse(mouseX+30,mouseY+30, 15,15);

fill(#dec83e);
ellipse(mouseX-30,mouseY-30, 10,10);

fill(#dec83e);
ellipse(mouseX-50,mouseY, 5,5);

fill(#dec83e);
ellipse(mouseX,mouseY-50, 10,10);

fill(#dec83e);
ellipse(mouseX+30,mouseY-20, 15,15);

fill(#dec83e);
ellipse(mouseX+50,mouseY, 5,5);
}
}

ADDING BUTTON TO CLEAR AREA

void setup()
{
size(480, 600); //Setting width, height
background(#9badaf); //Background color
}

void draw() {

//AREA TO DRAW IN
stroke(#ffffff);
noFill();
rect(30,30, 300,300);

//BUTTON
stroke(#ffffff);
fill(#ffffff);
rect(30,350, 100,30);

//CHECKING IF MOUSE PRESSED AND INSIDE RIGHT AREA

if ((mousePressed == true) && (mouseX>82) && (mouseX<278) && (mouseY>85) && (mouseY<293)) {

//MAIN CIRCLES WHERE MOUSE POINTER IS

//Large circle
fill(#d4a00d);
noStroke();
ellipse(mouseX,mouseY,50,50);

//Smaller circle
fill(#ddb834);
ellipse(mouseX,mouseY,35,35);

//Smallest circle
fill(#dec83e);
ellipse(mouseX,mouseY,15,15);

//SMALL DOTS OUTSIDE OF MOUSE POINTER

fill(#dec83e);
ellipse(mouseX+30,mouseY+30, 15,15);

fill(#dec83e);
ellipse(mouseX-30,mouseY-30, 10,10);

fill(#dec83e);
ellipse(mouseX-50,mouseY, 5,5);

fill(#dec83e);
ellipse(mouseX,mouseY-50, 10,10);

fill(#dec83e);
ellipse(mouseX+30,mouseY-20, 15,15);

fill(#dec83e);
ellipse(mouseX+50,mouseY, 5,5);

}

//CLEARING AREA WHEN BUTTON PRESSED

if ((mousePressed == true) && (mouseX>29) && (mouseX<131) && (mouseY>349) && (mouseY<380)){

//Make button gray when pressed
stroke(#ffffff);
fill(#cccccc);
rect(30,350, 100,30);

//Redraw area to draw in - clearing area
stroke(#ffffff);
fill(#9badaf);
rect(30,30, 300,300);
}
}

Lab #4 Analog input

Tuesday, October 5th, 2010

It’s time for Analog Input lab. Lab partner Erin and I are very excited. We love staying in the studio past midnight to play with our Arduino boards.

Parts we used:
Breadboard, hook up wire, wire stripper, multimeter, Arduino, LEDs, potentiometer, 330 Ohm resistors (or similar), 10K Ohm resistors (or similar), 1K Ohm resistors (or similar), variable resistor (we used the force resistor), glass of water

POTENTIOMETER SETUP

ADD AN LED FOR PWM OUTPUT

LOAD A PROGRAM TO CONTROL THE ARDUINO
We pasted in this code to our Arduino program:

int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
Serial.begin(9600);
}

void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val, DEC);
}

As we adjusted the potentiometer the output numbers changed. This is what we saw on our screen, using the Arduino program:

TRY OTHER VARIABLE RESISTORS
We tried a force sensing resistor like this:

With the multimeter and a 10K resistor – the more pressure we put on the variable resistor, the lower the voltage. The voltage was up to 4.8 volts, and as low as 1 volt. With a 1K resistor, the result was the same.

INVENTION
By the time we had done all this work, we became very thirsty. We could not believe that we had forgotten to drink this whole time. That’s why we invented a device that encourages forgetful drinkers to hydrate more often. We coded Arduino to give different messages depending on how full the water glass is:

  • GLASS FULL: Drink, or you’ll get dehydrated!
  • GLASS HALF FULL: Is your glass half full or half empty?
  • GLASS EMPTY: Thirsty? Fill her up!
  • GLASS LIFTED: Good job, isn’t that water tasty? :D

On the screen, the messages looked like this:

And Erin, our forgetful drinker, just kept filling the glass up, and drinking over and over again in an eternal loop, as we forgot (yeah, we tend to forget a lot of things) to program a message letting her know when enough is enough:

This was our code leaving the forgetful drinker to drink forever and ever:

int ledPin = 9; // LED connected to digital pin 9
int analogPin = 3; // potentiometer connected to analog pin 3
int val = 0; // variable to store the read value

void setup()
{
pinMode(ledPin, OUTPUT); // sets the pin as output
Serial.begin(300);
}

void loop()
{
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
if (val<=100) {
Serial.println("Good job, isn't that water tasty? :D ");
}
else if ((val>100) && (val<=275)) {
Serial.println("Thirsty? Fill her up!");
}
else if ((val>275) && (val<=340)) {
Serial.println("Is your glass half full or half empty?");
}
else if (val>340) {
Serial.println(“Drink, or you’ll get dehydrated!”);
}
}

Next time we’ll turn water into wine.

Imagined physical computing system

Wednesday, September 29th, 2010

Let’s invent something. Right. So that was the assignment. I decided to fix a quite trivial problem; my disorganized mornings, and more specifically create a device that would make sure that my purse contains everything it should contain when I go out the door. Like my keys:

By adding RFID-tags to my keys, phone, wallet etcetera, and have sensors by the door opening, I could get information about whether the items are in my purse or not. My very simple presentation, Call My Keys, might explain the rest. How this idea could be realized is not the important thing in this assignment. But if you’re eager to get one of these gadgets – it actually already exists if you’re willing to spend $160. So much for my creativity and innovation. Still, I feel my idea is a bit different then the Loc8tor I linked to… My device has its place on the wall by the door, but the Loc8tor could just as easily get misplaced as any of the items it’s programmed to locate. I can imagine the frustration people would have when they would need to locate the Loc8tor without having another Loc8tor to locate it!

Lab #3 Electronics

Saturday, September 25th, 2010


Parts we used: power jack, voltage regulator, LEDs, potentiometer, 330 Ohm resistors (or similar). In addition we used some already familiar tools like: breadboard, hook up wire, switch, power supply, solder, soldering iron, helping hands, needle-nose pliers, wire stripper, multimeter

MEASURING VOLTAGE

Instructions:
1. Wire up a breadboard with a 5-volt voltage regulator (7805) as shown. The regulator has three legs, typically, input, ground and output, when viewed from the front (where the writing is). Sometimes these legs are in a different order, so find and check the data sheet if you’re not sure! Input is where a high voltage is applied to the regulator. Output is where you will get the regulated 5 volts. Ground is the common ground for your entire circuit, including input, output and all the other components. Bring ground out to both blue ground rails that run along the sides of your breadboard. Bring 5 volt output power to both of the red power rails.

2. Solder a red wire (about 10 cm) to the short center pin of your power jack, and solder a similar black wire to the longer, outer pin. Test the connections with your multimeter to ensure they are good. Don’t allow the two connections to touch each other since that will create a short circuit when you power it up!

3. Attach the red wire from the power jack, using the breadboard to connect it to the input pin of the voltage regulator. Attach the black ground wire to the ground pin of the voltage regulator in the same way.

4. You are now ready to use your multimeter to check the voltages. Plug your power supply into the power jack. Switch your multimeter to the range for reading 0-20 volts, DC. Measure the voltage by touching the red probe to any bare wire on the power rail, and the black probe to any bare wire on the ground rail. You should read just about 5 volts. (4.97 or 5.03 is just fine).

Our setup:

My experience: Used about 2 hours to find a functioning power supply, and figure out how the power jack would work. Considering that our power jack had 3 pins, it was hard to find the right ones to solder wires to. We ended up using another power jack we found in the magical physical computing drawer at the studio that had only two pins. Then we were all set! We heard the BEEEP from the multimeter, and we could measure the voltage in the circuit. 5.01 volts. Success.

BASIC CIRCUIT

Instructions:
1. Disconnect your power supply and you’re ready to make your first basic electronic circuit.

2. Connect a momentary, normally open switch from power to the positive lead of an LED as shown.

3. Connect the negative lead of the LED to one lead of a 33o Ohm resistor (or similar) and connect the other lead of that resistor to ground.

4. Reconnect your power supply, then press the switch. Your LED should light up. The resistor reduces the amount of power flowing to the LED. If you didn’t use the resistor, your LED would light up but probably burn out very quickly.

5. Measure the voltage across the switch when it is closed, then across the LED and the resistor. What do you find?

Our setup:

My experience: Some questions came up:
- Why do we need the resistor?
- Which way does current flow through the circuits?
We didn’t exactly find the answers. BUT the LED was lighting up when button was pushed and the circuit was closed. That’s a good thing.

  • Measures when pressing button:
  • Voltage across switch: 0V
  • Voltage across LED and resistor: 3.44V
  • Measures when not pressing button:
  • Voltage across switch: 3.44V
  • Voltage across LED and resistor: 0V

Did not know why this was happening. Why would there be no voltage when button was pressed down and the circuit was whole??? But we moved on to the next task after scratching our head for a while :/

SERIES

Instructions:
1. Disconnect the power supply again, remove the switch and resistor, then connect two LEDs in series from power to ground.

2. Reconnect the power supply, and use your multimeter to test the voltage at different points in the circuit. What you you find?

3. Why don’t you need resistors in this circuit?

Our setup:

My experience:
When measuring the voltage of the LED lights in series, each LED light was 2.3V, and both of them was 4.6V. You won’t need resistors in this circuit because the LED lights eh… share the voltage (?).

PARALLEL

1. With the power supply disconnected, hook up three LEDs in parallel. (You may need to use a 330 Ohm resistor as your connection to ground to prevent the LEDs from overheating.) Measure the voltage across each LED and confirm that it is does not vary between each one.

2. Voltage is measured in parallel, so you do not need to interrupt the circuit in order to get a reading. To measure amperage (or current), you’ll need to put the multimeter in series with the circuit.

3. Switch the multimeter into DC amperage mode. You’ll be measuring not greater than 1 amp, so choose the correct range.

4. Interrupt the circuit so that current flows through the multimeter as part of the circuit. What is the current flow, in milliamps?

Our setup:

My experience: Setting up 3 LEDs in parallel was easy – and the voltage was the same on each of the LEDs (1.8V). The resistor was 1.6V, and the LEDs and the resistor combined added up to 3.4V. We then tried to measure the amperage of the circuit – but considering that the amperage measured was 0, we might not have done it the right way…

VARYING VOLTAGE

1. Solder three wires to the pins of your potentiometer. It’s helpful to have the two outer ones be red and black (it doesn’t matter which is which) with the middle one being another color like blue. Typically, the two outer pins are connected to power and ground, while the middle one produces a voltage that varies as the potentiometer is adjusted.

2. Create a circuit that varies the voltage flowing to an LED. First connect the potentiometer’s outer red and black wires to power and ground respectively. Then connect the middle wire from the potentiometer to a 330 Ohm resistor, and that 330 Ohm resistor to the positive leg of an LED. Connect the negative leg of the LED to ground.

3. Turn the knob on the potentiometer and measure the voltage coming off the middle wire. What readings do you get and how do they change? How does the LED’s output change?

Our setup:

My experience: When it came to the soldering, we simply skipped it because we were on the 4th hour of the lab – and coiling the wires around the hooks on the potentiometer worked just fine. We were ecstatic over the potentiometer’s ability to dim the light. We played around with it, and measured the voltage of the middle wire. The voltage was different according to how much we dimmed the light.

Archives

I have gathered some Physical Computing-related entries here. Just for you.

Search the blog

...or browse through the archives.