Recent Changes - Search:

Main
Intro to PComp Home
Weekly Topics & Assignments
Wednesday Class Dates

Links:

Final Projects


Midterm Projects

PmWiki

edit SideBar

GroupStoneglow

Group Members
Minsoo Lee
Greg Stringer
Rory Nugent

Proposal
We plan to improve upon the lightboxes we created for our midterm project.


Improvements

  • Infrared Light Modulation
Using the combination of an infrared emitter and a 38kHz IR detector module. This will allow for the blocking of ambient noise and will even allow us to "tag" the emitted light with data.
  • A more sophisticated enclosure, possibly a clear plastic cast.
  • Tricolor Super Bright LEDs will allow for a wider range of colors.
  • Use of the Arduino Mini to cut down on the size of the circuitry.


Parts (per stone)
1 x Arduino Mini
4 x 940nm Infrared Emitter Diodes
4 x TSOP-7000 Infrared Receiver Modules
1 x TX-IRHS Infrared Remote Control IC
1 x 20Mhz Ceramic Resonator
2 x 3V Lithium Coin Cell Batteries @ 165mA

Important Schematics


Breadboard + Enclosure


Source Code
//Rory Nugent, Gregory Stringer, Minsoo Lee
//Stoneglow Prototype
//Physical Computing

const int greenPin = 9;
const int bluePin = 10;
const int redPin = 11;

const int defaultColor = bluePin; //Stone specific
const byte stoneCode = 'B'; //Stone specific

int redValue = 0; //Stone specific
int greenValue = 0;
int blueValue = 255;

int breatheValue = 255;

bool startup = false;
bool breathing = false;

int redDirection = 20;
int greenDirection = 20;
int blueDirection = 20;
int breatheDirection = 1;

unsigned long time = 0;
unsigned long last_emission_time = 0;
unsigned long last_detection_time = 0;
unsigned long breathePause = 0;
unsigned long breatheChange = 0;

void setup() {

  Serial.begin(2400);
  pinMode(redPin,OUTPUT);
  pinMode(greenPin,OUTPUT);
  pinMode(bluePin,OUTPUT);

}

void loop() {

  time = millis();

  if(!startup)
    startupStone();

  checkBreathing();

  if(breathing)
  {
    analogWrite(redPin,breatheValue);
    analogWrite(greenPin,breatheValue);
    analogWrite(bluePin,breatheValue);
  }
  else
  {
    analogWrite(redPin,redValue);
    analogWrite(greenPin,greenValue);
    analogWrite(bluePin,blueValue);
  }

  checkDetectors();
  emitData();

}

void startupStone() {

  byte inByte = 0;
  byte lastByte = 0;
  unsigned long lastOn = 0;
  unsigned long lastOff = 0;

  while(!startup)
  {
      time = millis();
      if(time - lastOff > 100)
      {
        analogWrite(defaultColor,0);
        lastOff = millis();
      }
      else if(time - lastOn > 2000)
      {
        analogWrite(defaultColor,60);
        lastOn = millis();
      }
      emitData();

      if(Serial.available() > 0)
      {
        inByte = Serial.read();
        if((inByte == 'R' || inByte == 'G' || inByte == 'B') && inByte != stoneCode)
        {
          lastByte = inByte;
          while(Serial.available() <= 0) 
          {
            time = millis();
            if(time - lastOff > 100)
            {
              analogWrite(defaultColor,0);
              lastOff = millis();
            }
            else if(time - lastOn > 2000)
            {
              analogWrite(defaultColor,60);
              lastOn = millis();
            }
          }
          inByte = Serial.read();
          if(lastByte == inByte)
          {
            analogWrite(defaultColor,255);
            startup = true;
          }
        }
      }
  }

}

void checkBreathing() {

  delay(2);  //this is a weird fix... without it the tri-color will blink
  if(redValue >= 230 && greenValue >= 230 && blueValue >= 230)
  {
    breathing = true;
    if(breatheValue + breatheDirection > 255)
      breatheDirection *= -1;
    else if(breatheValue + breatheDirection < 0)
    {
      breatheValue = 0;
      breathePause = time = millis();
      while(time - breathePause <= 500)
        time = millis();
      breatheDirection *= -1;
    }
    time = millis();
    if(time - breatheChange > 12)
    {
      breatheValue += breatheDirection;
      breatheChange = millis();
    }
  }
  else
    breathing = false;

}

void checkDetectors() {

  byte inByte = 0;

  if(time - last_detection_time > 10)
  {
    if(Serial.available() > 0)
    {
      inByte = Serial.read();
      if(inByte == 'R' && stoneCode != 'R')
      {
        while(Serial.available() <= 0){}
        inByte = Serial.read();
        if(inByte == 'R')
        {
          if(redValue + redDirection > 255 || redValue + redDirection < 0)
            redDirection *= -1;
          redValue+=redDirection;
        }
      }
      else if(inByte == 'G' && stoneCode != 'G')
      {
        while(Serial.available() <= 0){}
        inByte = Serial.read();
        if(inByte == 'G')
        {
          if(greenValue + greenDirection > 255 || greenValue + greenDirection < 0)
            greenDirection *= -1;
          greenValue+=greenDirection;
        }
      }
      else if(inByte == 'B' && stoneCode != 'B')
      {
        while(Serial.available() <= 0){}
        inByte = Serial.read();
        if(inByte == 'B')
        {
          if(blueValue + blueDirection > 255 || blueValue + blueDirection < 0)
            blueDirection *= -1;
          blueValue+=blueDirection;
        }
      }
    }
    last_detection_time = millis();
  }

}

void emitData() {

  if(time - last_emission_time > 250)
  {
    Serial.print(stoneCode,BYTE);
    Serial.print(stoneCode,BYTE);
    last_emission_time = millis();
  }

}

Final Demo


Click the above picture to view a video of the final demo
Edit - History - Print - Recent Changes - Search
Page last modified on January 20, 2007, at 04:14 PM