Connie : Hallowuino

For this project I created a rather dramatically lit scene of a grizzly animal sacrifice to an elder god. There are red LEDs that fade up, as well as a single bright white one that blinks on a variable time setting – both these are hooked up to a photo sensor – so as a person approaches the piece and blocks the light the lighting gets more frenetic and creepy.

 

connie_1

 

[flickr video=8148300227 secret=d185d24547 w=400 h=225]

 

 
const int sensorPin = 0;
const int ledPin[ ] = {5, 6, 9, 10, 11};
const int blinky = 13;

int lightLevel, high = 0, low = 1023;
int flashTime;

void setup()
{
  Serial.begin(9600);
  for (int i=0; i<5; i++){
   pinMode (ledPin[i], OUTPUT); 
  }
  pinMode (blinky, OUTPUT);
}

void loop()
{
 
  lightLevel = analogRead(sensorPin); // 0....1023
 
  autoTune(); // this modifies lightLevel
 
  for (int i=0; i<5; i++){
    analogWrite(ledPin[i], lightLevel); // 0....255
  }
 
  //flashing();
  delay (1);
 
  flashTime = map (lightLevel,0,255, 2000, 65);
  int sec = millis()/flashTime;
  int whatToDo = sec %2;
  if (whatToDo == 0){
    digitalWrite(blinky, HIGH);
  } else {
    digitalWrite(blinky, LOW);
  }
 
}


void autoTune()
{
  if (lightLevel  high){
    high = lightLevel;
  }
 
  lightLevel = map(lightLevel, low+30, high-30, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);
}

 

Post a comment