Chile: http://tallerphysicalcomputing.blogspot.com
http://claymore.engineer.gvsu.edu/egr326/MW2
http://homeweb.mah.se/%7Ekid06025/bendsensor.html
laura palome
http://www.malmo.cc/org/org_pres.php3?nr=34981
Interaction Patters:
- russian roulette (similar to old dial) - swapping card - missile launching (two simultaneous keys to activate one device)
Motors: http://www.todorobot.com.ar/informacion/tutorial%20stepper/stepper-tutorial.htm
wiimote as 3d finger capture: http://www.everyoneforever.com/content/2007-11-13/space_touch_interface/
David's SvenskaForInvandrare course
Article on Microsoft buying the world for a hand full of dollars: http://www.elmundo.es/navegante/2004/11/17/empresas/1100708827.html
http://pzwart.wdka.hro.nl/mdma/

http://www.youtube.com/watch?v=yEamehAvcp8
Added support for flash movies, google video, youtube, and vimeo: http://www.pmwiki.org/wiki/Cookbook/Flash
Receiver
/*
* histeresys curve to respond to H and L commands coming through the Serial
*/
int outputPin = 8;
int val;
int countH;
// maximum time on
// change it to adjust times once installed
int maxCountH = 15;
void setup()
{
Serial.begin(9600);
pinMode(outputPin, OUTPUT);
}
void loop()
{
if (Serial.available()) {
val = Serial.read();
if (val == 'H') {
countH++;
}
if (val == 'L') {
countH--;
}
if(countH >= 5) {
digitalWrite(outputPin, HIGH);
}
else if(countH<2) digitalWrite(outputPin, LOW);
if(countH<0) countH = 0;
if(countH>maxCountH) countH = maxCountH;
Serial.println(countH,DEC);
}
}
Sender
int inputPin = 8; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
Serial.begin(9600);
pinMode(inputPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
Serial.print('L');
} else {
Serial.print('H');
}
delay(100);
}
umbrella
int sens1 = 12;
int sens2 = 13;
int recPin = 11;
int playPin = 10;
int val1 = 0;
int val2 = 0;
void setup()
{
Serial.begin(9600);
// prints title with ending line break
Serial.println("umbrella armed **");
pinMode(sens1, INPUT);
pinMode(sens2, INPUT);
pinMode(recPin, OUTPUT);
pinMode(playPin, OUTPUT);
digitalWrite(playPin, LOW);
digitalWrite(recPin, LOW);
delay(100);
}
int number = 33; // first visible character '!' is #33
void loop()
{
val1 = digitalRead(sens1);
val2 = digitalRead(sens2);
Serial.print(val1, DEC); // prints value unaltered, first will be '!'
Serial.print(" - ");
Serial.print(val2, DEC); // prints value as string in decimal (base 10)
Serial.println(); // prints value as string in binary (base 2)
// also prints ending line break
if(val1 == LOW && val2 == HIGH) {
digitalWrite(recPin, HIGH);
} else {
digitalWrite(recPin, LOW);
}
if((val1 == LOW && val2 == LOW)||(val1 == HIGH && val2 == HIGH)) {
digitalWrite(playPin, HIGH);
} else {
digitalWrite(playPin, LOW);
}
delay(500); // allow some time for the Serial data to be sent
}
an Otaku on an elevator
/*
Otaku controlled over IR
(cc) 2007 Sadi, made in RoK
*/
int servoPin = 6; // Control pin for servo motor
int minPulse = 500; // Minimum servo position
int maxPulse = 2500; // Maximum servo position
int pulse = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses
int analogValue = 0; // the value returned from the analog sensor
int analogPin = 1; // the analog pin that the sensor's on
void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulse = minPulse; // Set the motor position value to the minimum
Serial.begin(9600);
}
void loop() {
analogValue = analogRead(analogPin); // read the analog input
Serial.println(analogValue);
pulse = (analogValue * 19) / 10 + minPulse; // convert the analog value
// to a range between minPulse
// and maxPulse.
// pulse the servo again if rhe refresh time (20 ms) have passed:
for(int c = 0; c <=25; c++) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulse); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
delay(20); // save the time of the last pulse
}
}
Mike- training kit
#define HOOLA 3
#define ROPE 1
#define DUMBBEL 2
int incomingByte = 0; // for incoming serial data
int hoolaCount = 0;
int ropeCount = 0;
int dumbbelCount = 0;
int totalCount = 0;
int winningCounters = 0;
int winningLoop = 0;
int val = 0;
int oldWinner = 0;
int winner = 0;
int i = 0;
void restartCounters() {
hoolaCount = 0;
ropeCount = 0;
dumbbelCount = 0;
totalCount = 0;
}
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
restartCounters();
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
totalCount++;
switch(incomingByte){
case '3':
hoolaCount = hoolaCount + 1;
break;
// break is optional
case '1':
ropeCount = ropeCount + 1;
break;
case '2':
dumbbelCount = dumbbelCount + 1;
break;
}
}
if (totalCount >=20) {
if(hoolaCount >= ropeCount && hoolaCount >= dumbbelCount){
winner = HOOLA;
}
else if(ropeCount >= hoolaCount && ropeCount >= dumbbelCount){
winner = ROPE;
}
else if(dumbbelCount >= ropeCount && dumbbelCount >= hoolaCount){
winner = DUMBBEL;
}
if(oldWinner != winner || winningCounters > 40){
switch (winner) {
case HOOLA:
Serial.print("VPF");
Serial.print(32, BYTE);
Serial.print("3.mp3");
break;
case ROPE:
Serial.print("VPF");
Serial.print(32, BYTE);
Serial.print("1.mp3");
break;
case DUMBBEL:
Serial.print("VPF");
Serial.print(32, BYTE);
Serial.print("2.mp3");
break;
default:
Serial.print("VST");
}
Serial.print(13, BYTE);
winningCounters = 0;
Serial.flush();
delay(5000);
}
delay(1000);
restartCounters();
winningCounters++;
}
}
SRF05 Ultrasound sensor
/* Ultrasound Sensor
*------------------
*
* Reads values (00014-01199) from an ultrasound sensor (3m sensor)
* and writes the values to the serialport.
*
* http://www.xlab.se | http://www.0j0.org
* copyleft 2005 Mackie for XLAB | DojoDave for DojoCorp
*
*/
int ultraSoundSignalOut = 7; // Ultrasound signal pin
int ultraSoundSignalIn = 8; // Ultrasound signal pin
int val = 0;
int ultrasoundValue = 0;
int timecount = 0; // Echo counter
int ledPin = 13; // LED connected to digital pin 13
void setup() {
beginSerial(9600); // Sets the baud rate to 9600
pinMode(ledPin, OUTPUT); // Sets the digital pin as output
pinMode(ultraSoundSignalOut, OUTPUT); // Sets the digital pin as output
pinMode(ultraSoundSignalIn, INPUT); // Sets the digital pin as output
}
void loop() {
timecount = 0;
val = 0;
/* Send low-high-low pulse to activate the trigger pulse of the sensor
* -------------------------------------------------------------------
*/
digitalWrite(ultraSoundSignalOut, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(ultraSoundSignalOut, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(ultraSoundSignalOut, LOW); // Holdoff
/* Listening for echo pulse
* -------------------------------------------------------------------
*/
val = digitalRead(ultraSoundSignalIn); // Append signal value to val
while(val == LOW) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignalIn);
}
while(val == HIGH) { // Loop until pin reads a high value
val = digitalRead(ultraSoundSignalIn);
timecount = timecount +1; // Count echo pulse time
}
/* Writing out values to the serial port
* -------------------------------------------------------------------
*/
ultrasoundValue = timecount; // Append echo pulse time to ultrasoundValue
serialWrite('A'); // Example identifier for the sensor
printInteger(ultrasoundValue);
serialWrite(10);
serialWrite(13);
/* Lite up LED if any value is passed by the echo pulse
* -------------------------------------------------------------------
*/
if(timecount > 0){
digitalWrite(ledPin, HIGH);
}
/* Delay of program
* -------------------------------------------------------------------
*/
delay(100);
}
moving tile
#define AUTOMATIC 0
#define MANUAL 1
#define MOTOR_MAX 1850
#define MOTOR_MIN 1250
#define MOTOR_CENTERED 1500
#define LIMIT_UP 80
#define LIMIT_DOWN 70
#define STEP_UP 200
#define STEP_DOWN 100
#define MIC_THRESHOLD 505
#define MIC_MIN 506
#define TIMER_LIMIT 10000
#define NONE 0
#define UP 1
#define DOWN 2
#define TOP 3
int potPin = 2;
int ledPin = 9;
int micval = 0;
int timer = 0;
int position = 0;
int DEBUG = 1;
int mode = AUTOMATIC;
int move = NONE;
/// FUNCTIONS
void moveUp() {
position += STEP_UP;
if (position >= MOTOR_MAX) position = MOTOR_MAX;
moveMotor(LIMIT_UP,MOTOR_MAX);
timer = millis();
move = UP;
if (position == MOTOR_MAX) move = TOP;
}
void moveDown() {
position -= STEP_DOWN;
if (position <= MOTOR_MIN) position = MOTOR_MIN;
moveMotor(LIMIT_DOWN,MOTOR_MIN);
if (position == MOTOR_MIN) move = NONE;
}
void moveMotor(int limit, int angle) {
for(int i=0;i<limit;i++){
digitalWrite(ledPin, HIGH);
delayMicroseconds(angle); // the value 1850 makes it go "up"
digitalWrite(ledPin, LOW);
delay(20);
}
}
void calibration() {
while(Serial.read() != 'E') {
moveMotor(1,MOTOR_CENTERED);
}
position = MOTOR_MIN;
move = NONE;
}
/// END FUNCTIONS
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
Serial.println("** tile connected **");
Serial.print("** Mode: ");
if (mode == AUTOMATIC) Serial.println("AUTOMATIC");
else Serial.println("MANUAL");
}
void loop() {
if ( Serial.available()) {
int serin = Serial.read();
switch (serin) {
case 'A': // we enter automatic mode
Serial.println("** Entering Automatic Mode");
mode = AUTOMATIC;
break;
case 'M': // we enter manual mode
Serial.println("** Entering Manual Mode");
mode = MANUAL;
break;
case 'C': // we enter manual mode
if (mode == MANUAL) {
Serial.println("** Calibrating, use the screw in the motor");
calibration();
}
break;
case 'U': // move up manual mode
if (mode == MANUAL) {
Serial.println("Manual - Move up");
moveUp();
}
break;
case 'D': // move down manual mode
if (mode == MANUAL) {
Serial.println("Manual - Move down");
moveDown();
}
break;
default:
break;
}
}
if (mode == AUTOMATIC) {
micval = analogRead(potPin); // read the value from the sensor
if (DEBUG) {
Serial.println(micval);
}
if (micval<MIC_THRESHOLD){
if (DEBUG) {
Serial.println("Auto - Stepping Up");
}
moveUp();
}
if(move == DOWN){
if (DEBUG) {
Serial.println("Auto - Stepping Down");
}
moveDown();
}
if (DEBUG) {
delay(200);
}
if (millis()-timer >= TIMER_LIMIT && (move == UP || move == TOP)) {
move = DOWN;
}
}
}
IR-Receiver
int ir_pin = 7; //Sensor pin 1 wired through a 220 ohm resistor
int led_pin = 13; //"Ready to Receive" flag, not needed but nice
int debug = 0; //Serial connection must be started to debug
int start_bit = 2000; //Start bit threshold (Microseconds)
int bin_1 = 1000; //Binary 1 threshold (Microseconds)
int bin_0 = 400; //Binary 0 threshold (Microseconds)
void setup() {
pinMode(led_pin, OUTPUT); //This shows when we're ready to recieve
pinMode(ir_pin, INPUT);
digitalWrite(led_pin, LOW); //not ready yet
Serial.begin(9600);
}
void loop() {
int key = getIRKey(); //Fetch the key
if (key != -1) {
Serial.print("Key Recieved: ");
Serial.println(key);
}
}
int getIRKey() {
int data[12];
digitalWrite(led_pin, HIGH); //Ok, i'm ready to recieve
while(pulseIn(ir_pin, LOW) < 2200) { //Wait for a start bit
}
data[0] = pulseIn(ir_pin, LOW); //Start measuring bits, I only want low pulses
data[1] = pulseIn(ir_pin, LOW);
data[2] = pulseIn(ir_pin, LOW);
data[3] = pulseIn(ir_pin, LOW);
data[4] = pulseIn(ir_pin, LOW);
data[5] = pulseIn(ir_pin, LOW);
data[6] = pulseIn(ir_pin, LOW);
data[7] = pulseIn(ir_pin, LOW);
data[8] = pulseIn(ir_pin, LOW);
data[9] = pulseIn(ir_pin, LOW);
data[10] = pulseIn(ir_pin, LOW);
data[11] = pulseIn(ir_pin, LOW);
digitalWrite(led_pin, LOW);
if(debug == 1) {
Serial.println("-----");
}
for(int i=0;i<11;i++) { //Parse them
if (debug == 1) {
Serial.println(data[i]);
}
if(data[i] > bin_1) { //is it a 1?
data[i] = 1;
} else {
if(data[i] > bin_0) { //is it a 0?
data[i] = 0;
} else {
data[i] = 2; //Flag the data as invalid; I don't know what it is!
}
}
}
for(int i=0;i<11;i++) { //Pre-check data for errors
if(data[i] > 1) {
return -1; //Return -1 on invalid data
}
}
int result = 0;
int seed = 1;
for(int i=11;i>=0;i--) { //Convert bits to integer
if(data[i] == 1) {
result |= seed;
}
seed = seed * 2;
}
//patch for the weird data result
//I wish I knew wtf is wrong
for (int j = 0; j <= 11; j++) {
int aux = result;
aux -= pow(2, j);
if (aux < 0) {
result = j;
break;
}
}
if (result > 8) result = -1;
return result; //Return key number
}