# Theory and Practice of Tangible User Interfaces

### Announcements

November 24, 2007
Reading for November 27th, are now posted. Enjoy!

October 2, 2007
To upload your thoughtless acts, create a new assignment page like any other lab. You'll see "Thoughtless Acts" listed as one of the assignment options.

May 24, 2008
This site has been archived and is no longer editable. Stay tuned for the next version, coming in the fall!

# Lab 6

Project Members:
Kenghao Chang

In this homework, i create "Spin and win" game with the components i have learned. People can press on the FSR to trigger the plate spinning by DC motor. When they release the FSR, the DC motor would stop. While spinning, i use blue and green LEDs to blink alternately.

##### Components
• DC motor
• Blue and green LEDs
• 2AA batteries
• FSR
##### Code

int potPin = 0;   // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int ledPin1 = 11;
int ledPin2 = 10;
int val = 0;      // variable to store the value coming from the sensor
int counter = 0;
int counterMax = 1000;
int ledValue = 0;
void setup() {
Serial.begin(9600);

}
void loop() {
val = analogRead(potPin);    // read the value from the sensor, between 0 - 1024
Serial.println(val);

if (val/4 > 100) {
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
analogWrite(ledPin1, ledValue);
analogWrite(ledPin2, 255 - ledValue);
ledValue = 255 - ledValue;
delay(50);
} else {
analogWrite(motorPin, 0);
analogWrite(ledPin1, 255);
analogWrite(ledPin2, 255);

}

}

##### Demo

Nice skill game, with a simple interaction that's still challenging! It's an interesting foundation to augment with other types of interaction. For example, how could two players interact while playing together? What other types of "zones" could be on the spinning disk? And how would someone keep score? Games with motion seem to be inherently fun...!