Physical Computing Projects

From Zackipedia

Jump to: navigation, search

Contents

Progress 9/29

  • So live interaction with a computer is really hard
  • So strings don't exist "as is" in Arduinos, you need arrays of characters [1]
  • Here's something on reading RPM from Fans (good for using Fans as input devices) - [2]
  • Probably should buy an LCD Screen -> [3]
  • Also need to buys fans [4]
  • Oh wait, it is possible to interact with the computer, and not hard at all!
    • Example of code running through the USB to the Arduino and back out: [5]
    • Basically, you use "serial" communication -> [6]
  • At the End of the Day, I am playing with the Dimmer [7]
    • Good for testing Computer -> Arduino Interaction

Progress 10/6

  • Ideas remain loose and uncertain
  • Nothing compelling, no steady way forward
  • Play with Servo Motor Control [8]

Costs

  • Bulletin Board -> $7.49
  • Tacks (20 - Red) -> $1.49
    • Total : $9.61

More Progress

  • Finally got the Dimmer thing to work (see above)
  • Very cool -> Requires a Processing Program to run simultaneously
    • Basically you # Upload Arduino Code
                # Run Processing Applet (which feeds in Live data)

Progress 10/7

  • On Colleen's Suggestion, I decided to develop a Rock - Paper - Scissors Interface
  • Now trying to add further functionality.

Code

/*
  Simple Rock Paper Scissors Interface
  
  Coded by Zachary McCune, last edits Oct. 7, 2009 
 */
// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin1 = 2;   // the number of the pushbutton pin
const int buttonPin2 = 4;
const int buttonPin3 = 7;
const int ledPin1 =  13;  // the number of the LED pin
const int ledPin2 =  11;
const int ledPin3 =  9;
const int victoryPin = 12; 

boolean buttonPressed1 = false;
boolean buttonUnpressed1 = true; 

boolean buttonPressed2 = false;
boolean buttonUnpressed2 = true;

boolean buttonPressed3 = false;
boolean buttonUnpressed3 = true;

// variables will change:
int buttonState1 = 0;    // variable for reading the pushbutton status
int buttonState2 = 0; 
int buttonState3 = 0;
void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT);  
  pinMode(ledPin2, OUTPUT); 
  pinMode(ledPin3, OUTPUT); 
  pinMode(victoryPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT); 
  pinMode(buttonPin2, INPUT); 
  pinMode(buttonPin3, INPUT); 
  Serial.begin(9600);
}
void loop(){
  // read the state of the pushbutton value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
 

// BUTTON 1 ------- ROCK

  if (buttonState1 == HIGH) { 
    //rock    
    // turn LED on:    
    digitalWrite(ledPin1, HIGH);
    buttonPressed1 = true;
    
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin1, LOW); 
    buttonUnpressed1 = true; 
    if (buttonPressed1 == true && buttonUnpressed1 == true) { 
      rps();
    }
    buttonUnpressed1 = false;
    buttonPressed1 =false;
    //buttonMemory = 0;
  }

//BUTTON 2 ------ PAPER

  if (buttonState2 == HIGH) {     
    // paper
    // turn LED on:    
    buttonPressed2 = true;
    digitalWrite(ledPin2, HIGH);   
  } 
  
  else {
    // turn LED off:
    digitalWrite(ledPin2, LOW); 
   buttonUnpressed2 = true; 
    if (buttonPressed2 == true && buttonUnpressed2 == true) { 
      rps();
    }
    buttonUnpressed2 = false;
    buttonPressed2 =false;
  }
  

//BUTTON 2 ------- SCISSORS

   if (buttonState3 == HIGH) {     
    // turn LED on:    
    //scissors
    digitalWrite(ledPin3, HIGH); 
    buttonPressed3 = true;
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin3, LOW);
    buttonUnpressed3 = true; 
    if (buttonPressed3 == true && buttonUnpressed3 == true) { 
      rps();
    }
    buttonUnpressed3 = false;
    buttonPressed3 =false; 
  }
}

int rps() { 
  //0 is Rock
  //1 is Paper
  //2 is Scissors
  
  int winNumber = random(3);
      
      //determining if you won
      if (winNumber == 0) { 
         digitalWrite(victoryPin, HIGH);
         delay(2000); 
         digitalWrite(victoryPin, LOW);
      }
      else {
        digitalWrite(victoryPin, LOW);
      }
  
  // long randNumber = random(3);
   Serial.println(winNumber);
  // return randNumber;  
 }
Personal tools