Team:TU Munich/lab/notebook/lightbox

From 2011.igem.org

Lightbox design

People: Fabian, Leonhard

For the assays an apparatus to irradiate the bacteria with light of different wavelengths was needed. Basically any sufficiently dark box that is small enough to fit in your incubator is usable as chassis.

We used an old paperboard container and drilled some small holes into it to fix the LEDs (we used the wavelengths 450 for blue light activation, 650 for red light deactivation and 710 for red light activation).

On the inside the tubes with the bacteria need to be adequatly bound to the box such that they dont damage anything.

To do the dimming and on and off switching of LEDs we used a Arduino board with the following setup and code:

Setup

Sketch.jpg

Code

int inPinmod = 2;
int inPindim = 4;// the number of the input pin
int redoffPin = 11;       // the number of the output pin
int redonPin = 9;
int blueonPin = 10;

int state = 0;      // the current state of the output pin
int readingmod;  
int readingdim;  // the current reading from the input pin
int previousmod = LOW; 
int previousdim = LOW; // the previous reading from the input pin
int intensity = 255;

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long modtime = 0;
long dimtime = 0; // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup()
{
  Serial.begin(9600);
  pinMode(inPinmod, INPUT);
  pinMode(inPindim, INPUT);
  pinMode(redoffPin, OUTPUT);
  pinMode(redonPin, OUTPUT);
  pinMode(blueonPin, OUTPUT);
}

void loop()
{
  readingmod = digitalRead(inPinmod);
  readingdim = digitalRead(inPindim);

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (readingmod == HIGH && previousmod == LOW && millis() - modtime > debounce) {
    if (state < 5)
      state = state + 1;
    else
      state = 0;
    modtime = millis();    
    Serial.println(state);
  }
  if (readingdim == HIGH && previousdim == LOW && millis() - dimtime > debounce) {
    if (intensity < 255) {
      intensity = intensity + 64;
      if (intensity == 64 ) {
       intensity = 63;
      }
    }
    else {
      intensity = 0;
    }
    dimtime = millis();    
    Serial.println(intensity);
  }


  switch (state) {
    case 0:
      analogWrite(redoffPin,  0);
      analogWrite(redonPin, 0);  
      analogWrite(blueonPin, 0);
      break;    
    case 1:
      analogWrite(redoffPin, intensity);
      analogWrite(redonPin, 0);  
      analogWrite(blueonPin, 0);
      break;
    case 2:
      analogWrite(redoffPin, 0);
      analogWrite(redonPin, intensity);  
      analogWrite(blueonPin, 0);
      break;
    case 3:
      analogWrite(redoffPin, 0);
      analogWrite(redonPin, 0);  
      analogWrite(blueonPin, intensity);
      break;
    case 4:
      analogWrite(redoffPin, 0);
      analogWrite(redonPin, intensity);  
      analogWrite(blueonPin, intensity);
      break;
    case 5:
      analogWrite(redoffPin, intensity);
      analogWrite(redonPin, 0);  
      analogWrite(blueonPin, intensity);
      break;
    default: 
      analogWrite(redoffPin, 0);
      analogWrite(redonPin, 0);  
      analogWrite(blueonPin, 0);
      break;
  }

  previousmod = readingmod;
  previousdim = readingdim;
}