Light and Interactivity

Week 7_Lamp Fixture

I made an interactive sunflower lamp.

Code
 
#include <Adafruit_NeoPixel.h>
#include <Servo.h>
#define PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
Servo myservo; 

const int PIRPin = 2;
int PIRstate; 
int val;
int pos = 0; 

void setup() {
  pinMode(PIRPin, INPUT); //declare PIR as input
  PIRstate = digitalRead(PIRPin);
  strip.begin();
  strip.setBrightness(255); //adjust brightness here
  strip.show(); // Initialize all pixels to 'off'
  myservo.attach(9); 
}

void loop() {

  val = digitalRead(PIRPin); // read input value
  if (val != PIRstate) // check if the input has changed
  {
   if(val == HIGH){
     for (pos = 0; pos <= 40; pos += 1) { // goes from 0 degrees to 180 degrees
     // in steps of 1 degree
     myservo.write(pos);              // tell servo to go to position in variable 'pos'
     delay(15);                       // waits 15ms for the servo to reach the position
   }
  for (pos = 40; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  
  colorWipe(strip.Color(255, 100, 0), 50); 
  colorWipe(strip.Color(255, 50, 0), 50); 
  colorWipe(strip.Color(255, 0, 0), 50); 
  }
    else{
    }
  }
  PIRstate = val; 
}

void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

Fabrication
I used the laser cutter and CNC to make the structure of the lamp.
Here is the file:

 

Then set them up:

One thought on “Week 7_Lamp Fixture

Leave a Reply

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