I like summer. So I wanted to create the summer vibe in my room. I think sunflower is the icon of summer, and especially when the fresh breeze blowing over and the petals swaying.
This installation repents the image of sunflowers and imitates the swaying when people passing by.
</span> <pre>#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 acrylic structure of the lamp.
Here is the design file:
Then set them up:
Primary components:
Arduino Uno/ PIR sensor/Servo/LED
Leave a comment