This reads in different resistance, and display different color rectangle.

Arduino

int analPin = 1;                       // Analog pin connected to pin 1
analPin

void setup() {
  pinMode(switchPin, INPUT);             // Set pin 0 as an input
  Serial.begin(9600);                    // Start serial communication at 9600 bps
}

void loop() {

  Serial.print(analogRead(analPin, Byte));
  delay(100);                            // Wait 100 milliseconds
}

*/

Processing side


import processing.serial.*;

Serial myPort;  // Create object from Serial class
int val;      // Data received from the serial port

void setup() 
{
  size(200, 200);
  // I know that the first port in the serial list on my mac
  // is always my  FTDI adaptor, so I open Serial.list()[0].
  // On Windows machines, this generally opens COM1.
  // Open whatever port is the one you're using.
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}

void draw()
{
  if ( myPort.available() > 0) {  // If data is available,
    val = myPort.read();         // read it and store it in val
  }
  background(255);             // Set background to white
  if (val <500) {              // If the serial value is 0,
    fill(0);                   // set fill to black
  } 
  else {                       // If the serial value is not 0,
    fill(204);                 // set fill to light gray
  }
  rect(50, 50, 100, 100);
}

Virtual Creature Creator

Abstract:

Idea is to create a creature physically and bring it to life virtually.

Related Works:

  • Posey

    This is a construction kit that allows user to build an interface for application running on computer.

  • Designosaur

    User can use physical parts to build a dinosaur, and the dinosaur will be displayed on modeling application.

Design Details:

User will be able to use different orientations and combination of physical parts to create a unique creature, which will come to life in Processing. User will be able to define a set of physical and behavior properties using these physical parts.  By connecting the physical pieces to Arduino board, Arduino board would send data about the orientation and combination of physical components to Processing. Processing will then create a virtual creature in an environment with different physics applied.

User can then interface with the creature in Processing.

I am also thinking about possible interaction between the physical and virtual components.

This is for fun and probably more for younger age group. I would play with it too though.


Skills List:

  • Processing, and the sending useful data from Arduino to Processing
  • Using hardware components and getting orientation/combination data

Parts List:

  • Physical parts to build creature

4-week timeline

  • Week 1: Figure out how hardware will work and look at different parts
  • Week 2: Build small scale parts to make sure concept works between hardware and Processing
  • Week 3; Build up the physical parts and the Processing application
  • Week 4: Finish project and wrap up documentation

Wearable Alarm Clock

In this project, I worked on a shirt that also acts are your alarm clock. The motivation behind it was I wanted to create an alarm clock that is not so easy to get rid of in the morning. If alarm clock is embedded in your clothing, hopefully it will “alarm” you more in the morning and also be harder to get rid of.

 

I used 12 button keypad to set the time duration until alarm sets off, and used buzzer + vibrator as the output device. Biggest challenge I had was trying to figure out the 12 button keypad input, because the documentation provided online wasn’t consistent with the device I used.  

Photos:

 

 

Here’s the code I used:

 

/*

 * Author: Sungjoon Steve Won (stevewon@gmail.coM)

 */

 

//Pin indicator for the keypad matrix

int row1 = 10;

int row2 = 7;

int row3 = 8;

int row4 = 9;

int col1 = 12;

int col2 = 13;

int col3 = 11;

 

//Variables declared to deal with keypad input

int val1 = 0;

int val2 = 0;

int val3 = 0;

int val4 = 0;

int val5 = 0;

int val6 = 0;

int val7 = 0;

 

 

int vibratorPin = 2; //output pin for vibrator

int buzzerPin = 3; //output pin for buzzer

int ledPin = 4; //pin for LED

 

//Other indicators

int alarmOff = 0; //If set to 1, alarm should go off

int setAlarmNext = 0; //If set to 1, set alarm next time loop comes around

 

void setup() {

  pinMode(row1, INPUT);

  pinMode(row2, INPUT);  

  pinMode(row3, INPUT);  

  pinMode(row4, INPUT);     // declare pushbutton as input

  pinMode(col1, OUTPUT);

  pinMode(col2, OUTPUT);  

  pinMode(col3, OUTPUT);  

 

  pinMode(buzzerPin, OUTPUT); //Buzzer pin

  Serial.begin(9600);

 

}

 

void loop(){

  int thisKey = getKey(); //Detect input from keypad

 

 

  if (thisKey == 10) { //If input if “*”, use it to set Alarm.

 

    digitalWrite(ledPin, HIGH);   // sets the LED on

    delay(1000);                  // waits for a second

    digitalWrite(ledPin, LOW);    // sets the LED off

    delay(1000);                  // waits for a second

 

    setAlarmNext = 1;

    Serial.println(“3”);

 

    thisKey = getKey();

    int alarmDuration = thisKey * 1000; //For the purposes of demonstration, make alarm keypad number seconds

    delay(alarmDuration); 

 

    int wakeUpSteps = 10; //steps used to determine how strong wake-up alerts should be

    do {

      wakeUp(wakeUpSteps);

      thisKey = getKey();

      wakeUpSteps–; //Make it stronger & faster next time

    }

    while (thisKey != 11);

    analogWrite(vibratorPin, 0); //turn off vibrator

 

 

    Serial.println(“2”);   

   }

}

 

//Function that calls buzz and vibrate functions.

void wakeUp(int stepNum) {

    if (stepNum <= 1) {

      analogWrite(vibratorPin, (2000));  //Vibrate 

      buzz(buzzerPin, 2500, 500); // buzz the buzzer on pin 4 at 2500Hz for 1000 milliseconds

      delay(100); // 1 second delay

    }

    else {

      analogWrite(vibratorPin, (1000-stepNum*100));  //Vibrate 

      buzz(buzzerPin, 2500, 500); // buzz the buzzer on pin 4 at 2500Hz for 1000 milliseconds

      delay(stepNum*100); // 1 second delay

    }

}

 

 

//10 = *

//11 = #

int getKey() {

  digitalWrite(col1, HIGH);

  digitalWrite(col2, LOW);

  digitalWrite(col3, LOW);

 

 

  if (digitalRead(row1) == HIGH) {

     Serial.print(“Num 1\n”); 

     return 1;

  }

  if (digitalRead(row2) == HIGH) {

     Serial.print(“Num 4\n”); 

     return 4;

  }

  if (digitalRead(row3) == HIGH) {

     Serial.print(“Num 7\n”); 

     return 7;

  }

  if (digitalRead(row4) == HIGH) {

     Serial.print(“Num *\n”); 

     return 10;

  }

 

  digitalWrite(col1, LOW);

  digitalWrite(col2, HIGH);

  digitalWrite(col3, LOW);

 

 

  if (digitalRead(row1) == HIGH) {

     Serial.print(“Num 2\n”); 

     return 2;

  }

  if (digitalRead(row2) == HIGH) {

     Serial.print(“Num 5\n”); 

     return 5;

  }

  if (digitalRead(row3) == HIGH) {

     Serial.print(“Num 8\n”); 

     return 8;

  }

  if (digitalRead(row4) == HIGH) {

     Serial.print(“Num 0\n”); 

     return 0;

  }

 

 

  digitalWrite(col1, LOW);

  digitalWrite(col2, LOW);

  digitalWrite(col3, HIGH);

 

 

  if (digitalRead(row1) == HIGH) {

     Serial.print(“Num 3\n”); 

     return 3;

  }

  if (digitalRead(row2) == HIGH) {

     Serial.print(“Num 6\n”); 

     return 6;

  }

  if (digitalRead(row3) == HIGH) {

     Serial.print(“Num 9\n”); 

     return 9;

  }

  if (digitalRead(row4) == HIGH) {

     Serial.print(“Num #\n”); 

     return 11;

  }

 

  digitalWrite(col1, LOW);

  digitalWrite(col2, LOW);

  digitalWrite(col3, LOW);

 

  return -1;

}

 

//Imported from http://rob.faludi.com/itp/arduino/buzzer_example.pde

void buzz(int targetPin, long frequency, long length) {

  long delayValue = 1000000/frequency/2; // calculate the delay value between transitions

  //// 1 second’s worth of microseconds, divided by the frequency, then split in half since

  //// there are two phases to each cycle

  long numCycles = frequency * length/ 1000; // calculate the number of cycles for proper timing

  //// multiply frequency, which is really cycles per second, by the number of seconds to 

  //// get the total number of cycles to produce

 

  for (long i=0; i < numCycles; i++){ // for the calculated length of time…

    digitalWrite(targetPin,HIGH); // write the buzzer pin high to push out the diaphram

    delayMicroseconds(delayValue); // wait for the calculated delay value

    digitalWrite(targetPin,LOW); // write the buzzer pin low to pull back the diaphram

    delayMicroseconds(delayValue); // wait againf or the calculated delay value

  }

}

Blinking Beanie

Here, I put LED into the back of my beanie and made it blink whenever I pressed on a button that placed in the side of the beanie. The rate LED blinks increase and decreases as the button is pressed longer.

Code

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for a pushbutton)
int val = 0;                    // variable for reading the pin status
long randNumber;
int blinkDuration;
int decrease;
void setup() {
pinMode(ledPin, OUTPUT);      // declare LED as output
pinMode(inputPin, INPUT);     // declare pushbutton as input
blinkDuration = 1000;         // default blinking duration
decrease = 1;                 // indicator where 1 = blinking rate will decrease and 0 = blinking rate will increase
}

void loop(){
val = digitalRead(inputPin);  // read input value

if (val == HIGH) {            // check if the input is HIGH
digitalWrite(ledPin, LOW);  // turn LED OFF
} else {
if (decrease == 1) { //Decrease the blinking rate
if (blinkDuration <= 100) { //Next time loop comes around, increase blinking rate.
decrease = 0;
blinkDuration = 100;
}
else {
blinkDuration = blinkDuration – 50;
}
}
else { //Increase the blinking rate
if (blinkDuration >= 1000) { //Next time loop comes around, decrease blinking rate.
decrease = 1;
blinkDuration = 1000;
}
else {
blinkDuration = blinkDuration + 50;
}
}

digitalWrite(ledPin, HIGH);   // sets the LED on
delay(blinkDuration);                  // waits for a second

digitalWrite(ledPin, LOW);    // sets the LED off
delay(200);        // waits for a second

}
}

Blinking Monkey

My project involved a monkey doll and detecting how close someone is. The biggest problem I had was getting the infrared proximity to get correct readings (which I couldn’t get working in time), and opted out to using a potentiameter as a replacement. Please assume I used a proximity sensor when reading the description below.

The monkey had a set of LED’s, three rows where each row had different color, in the front.

If someone is very far away, the LEDs would fade in and out. Once someone is closer, each row of LEDs would blink alternatively but at a faster rate as someone gets closer. Once someone is very close, all the LEDs would all blink together (at a faster rate as someone gets closer).

Video demo

http://www.vimeo.com/1810723

Code

/*
* AnalogInput
* by DojoDave <http://www.0j0.org&gt;
*
* Turns on and off a light emitting diode(LED) connected to digital
* pin 13. The amount of time the LED will be on and off depends on
* the value obtained by analogRead(). In the easiest case we connect
* a potentiometer to analog pin 2.
*
* http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 9;   // select the pin for the LED
int ledPin2 = 10;   // select the pin for the LED
int ledPin3 = 11;   // select the pin for the LED

int val = 0;       // variable to store the value coming from the sensor
int value = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
pinMode(ledPin2, OUTPUT);  // declare the ledPin as an OUTPUT
pinMode(ledPin3, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
val = analogRead(potPin);    // read the value from the sensor
Serial.print(val);
Serial.print(“\n”);

if (val > 500) {
for(value = 0 ; value <= 100; value+=5) // fade in (from min to max)
{
analogWrite(ledPin, value);           // sets the value (range from 0 to 255)
analogWrite(ledPin2, value);           // sets the value (range from 0 to 255)
analogWrite(ledPin3, value);           // sets the value (range from 0 to 255)
delay(50);                            // waits for 30 milli seconds to see the dimming effect
}
for(value = 100; value >=0; value-=5)   // fade out (from max to min)
{
analogWrite(ledPin, value);
analogWrite(ledPin2, value);
analogWrite(ledPin3, value);
delay(50);
}
}

else if (val < 200) {
digitalWrite(ledPin, HIGH);  // turn the ledPin on
digitalWrite(ledPin2, HIGH);  // turn the ledPin on
digitalWrite(ledPin3, HIGH);  // turn the ledPin on
delay(val);                  // stop the program for some time

digitalWrite(ledPin3, LOW);   // turn the ledPin off
digitalWrite(ledPin2, LOW);   // turn the ledPin off
digitalWrite(ledPin, LOW);   // turn the ledPin off
delay(val);                  // stop the program for some time

}
else {
digitalWrite(ledPin, HIGH);  // turn the ledPin on
delay(val);                  // stop the program for some time
digitalWrite(ledPin2, HIGH);  // turn the ledPin on
delay(val);                  // stop the program for some time
digitalWrite(ledPin3, HIGH);  // turn the ledPin on
delay(val);                  // stop the program for some time

digitalWrite(ledPin3, LOW);   // turn the ledPin off
delay(val);                  // stop the program for some time
digitalWrite(ledPin2, LOW);   // turn the ledPin off
delay(val);                  // stop the program for some time
digitalWrite(ledPin, LOW);   // turn the ledPin off
delay(val);                  // stop the program for some time
}
}