match lamp
I want to make a lamp with high technology, but it looks very ordinary. People should not forget the match that brings light to us.
Research:
The smart home market will take off if IoT device prices come down and the general public comes to understand the benefits of these products. And from smart homes, the next logical step is smart cities, which would take the IoT to the next level.
Inspiration:
The movement of the user is tracked using the light bulb to create digital art. properties such as speed, vector, rotation are determined for each particle based on the movement of the user. I was considering about some motion tracking with the smart home.
The match was the first tool to bring light to people. I want to make a normal surface likes like the matchbox with high technology.
Description:
- Material: Infrared Obstacle Avoidance Sensor
- Sound Microphone Sensor,RGB LED strip
- Skill: laser cutting, Arduino
- Target population: young people who like new things
Test vedio:
Demo:
1.Functuon:Infrared Obstacle Avoidance Sensor & LED
2.Function:Sound Microphone Sensor & LED
Code:
#include <Adafruit_NeoPixel.h>
#define PIN 6
int Led = 15;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Led, PIN, NEO_GRB + NEO_KHZ800);
int state =0;
int ledNum;
int val;
int buttonPin0 =2;
int buttonPin1 =3;
boolean buttonState0 = false;
boolean buttonState1 = false;
long st,st0,st1;
int changdiState = 0;
long changdiTime;
void setup() {
Serial.begin(9600);
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}
void loop() {
ButtonCK();
if(state==1){
if(millis()-st>100 & ledNum<Led){
st=millis();
ledNum++;
strip.setPixelColor(ledNum, strip.Color(200, 0, 200));
}
}else if(state==2){
ledNum=0;
rainbowCycle(20);
}else if(state==3){
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
}else{
ledNum=0;
for(int i=0; i<Led; i++){
strip.setPixelColor(i, strip.Color(0, 0, 0));
}
}
strip.show();
}
void ButtonCK(){
buttonCheck();
val=analogRead(A0);
if(changdiState==0 & buttonState0 & millis()-changdiTime>500){
changdiState=1;
changdiTime=millis();
}
if(changdiState==1 & buttonState1){
state++;
changdiState=0;
}
if(state>3)state=1;
if(val>800){
state=0;
}
Serial.print(val);
Serial.print(“,”);
Serial.println(state);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
ButtonCK();
}
ButtonCK();
if(state!=2)break;
strip.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 – WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 – WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 – WheelPos * 3);
}
}
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);
ButtonCK();
if(state!=3)break;
}
}
void buttonCheck(){
if(!buttonState0 & !digitalRead(buttonPin0)){
st0=millis();
buttonState0 = true;
}else if(buttonState0 & digitalRead(buttonPin0)){
buttonState0 = false;
}
if(!buttonState1 & !digitalRead(buttonPin1)){
st1=millis();
buttonState1 = true;
}else if(buttonState1 & digitalRead(buttonPin1)){
buttonState1 = false;
}
}