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!


LightBloom

Project Members: 
Ken-ichi Ueda

Description

This time I wanted to make something computationally simply buth mechanically complex. I also didn't want to stay up until 3am again. I think did ok with the first 2, not so much on the third.

All I set out to do was make a paper flower and lit up when you opened it. The way it ended up working was that a cardboard disk was affixed to the pot with silly putty, and hinged struts coming off the wheel attached to the leaf petals. When you opened or closed the petals, the disc and the pot would rotate, and the program would adjust the LED brightness accordingly. The wider you open the petals, the brighter the LED gets. The putty didn't do a great job sticking the flower to the disc (it slipped a lot), so I wrote in a serial command ("c") to declare the flower as closed.

Components Used

  • Resistor
  • LED
  • Pot
  • Silly Putty
  • Cardboard
  • Paper

Arduino Code

/** 
 * LightBloom
 *
 * Just a simple app that fires an LED over PWM in response to a pot.
 *
**/

int potPin = 0; // select the input pin for the potentiometer
int ledPin = 10;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor
int bval = 0;      // current brightness value
int cval = 500;    // current pot value declared as flower closed
int BRANGE = 170;  // range of values from the pot (limited by flower)

// serial input vars
char serInString[100];
char cmd;

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
  Serial.begin(9600);
}
void loop() {
  readSerialString(serInString);
  cmd = serInString[0];
  
  val = analogRead(potPin);    // read the value from the sensor
  
  if (cmd == 'c') { // if flower declared as closed
    serInString[0] = 0;  
    cval = val; // set closed val to current
    analogWrite(ledPin, 0);
    Serial.print("Flower closed at ");
    Serial.println(cval);
  }
  
  bval = (int) (((float) val - (float) cval) / (float) BRANGE * 255.0); // scale brightness

Serial.print("Pot: ");
  Serial.println(val);
  Serial.print("cval: ");
  Serial.println(cval);
  Serial.print("bval: ");
  Serial.println(bval);
  analogWrite(ledPin, bval);  // turn the ledPin on

delay(100);
}

//read a string from the serial and store it in an array
//you must supply the array variable
void readSerialString (char *strArray) {
  int i = 0;
  if(!Serial.available()) {
    return;
  }
  while (Serial.available()) {
    strArray[i] = Serial.read();
    i++;
  }
} 

Pictures

Kryptonic Bloom

The Beast Within


Powered by Drupal - Design by Artinet