Acrylic LED Art Project: Daily Log #5

Today I continued work on the baseplate design. Last Wednesday Mr. Stancik was absent, so we had to work on something else. On Friday, we work on our VEX robot for the competition on Saturday. Today, I got back to work. The baseplate design is a lot harder, because you have to account for wires, LEDs, and the image plate. You’re also designing a 3D box with a 2D image, which can be difficult. I’ve also finished the code: 

void loop() {
  int ss = 20; // sample size for light sensor
  int average = 0; 
  for (int x = 0; x < ss; x++) { // take several readings
    // mapping to correct values
    average += map(analogRead(0), 0, 1023, 0, 127); 
    delay(3);
  }
  average /= ss;
  //Serial.println(analogRead(0));
  //Serial.println(average);
  if (oldavg == 0) {
    oldavg = average;
  }
  if (abs(oldavg - average) > 1) { // smoothly transition colors
    Serial.print("Goal: "); 
    Serial.println(average);
    digitalWrite(13, HIGH);
    while (oldavg < average) {
      oldavg += 2;
      setColor(oldavg);
    }
    while (oldavg > average) {
      oldavg -= 2;
      setColor(oldavg);
    }
    digitalWrite(13, LOW);
  }
}

void setColor(int hue) {
  CRGB color = CHSV(hue, 255, 255);
}

It reads the light sensor and maps the value to color values which are then processed with a transition from the previous color.

Leave a Reply

Your email address will not be published. Required fields are marked *