meilily LiRain YeJohn HenryKishor Maharjan
Published

The Little Universe, a Gesture-Controlled Floor Lamp

The Little Universe is a gesture-controlled floor lamp with three wooden legs and an artistic lamp head.

IntermediateFull instructions provided4 hours1,146

Things used in this project

Hardware components

Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
Seeed Studio Seeeduino Lotus V1.1 - ATMega328 Board with Grove Interface
×1
Seeed Studio Seeed Grove - Gesture(PAJ7620U2)
×1
Seeed Studio Flexible Waterproof LED Strip - RGB
×1
Seeed Studio USB Power Plug Adapter
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Circular ABS shafts
PVC tube
yellow flaxen thread
bench drill
hand saws
table saw

Story

Read more

Code

gesture control

Arduino
#include <paj7620.h>
#include <Adafruit_NeoPixel.h>


#define NP_PIN  2
#define NUMPIXS 30
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXS, NP_PIN, NEO_GRB + NEO_KHZ800);  
uint8_t npState = 0;
float npLevel = 0.8;
uint8_t colorList[5][3]={{250,120,80}, {250,215,18}, {215,0,215}, {0,128,225}, {0,183,0}};
uint8_t color[3] = {250,120,80};
uint8_t myColor[3] = {250,120,80};
uint8_t npIdx = 0;
uint16_t lock_ms = 0;

void setup() {
  // put your setup code here, to run once:
  pixels.begin(); // This initializes the NeoPixel library.
  paj7620Init();
  pixels.clear();
  pixels.show();
}

void loop() {
  uint8_t data = 0;
  lock_ms = 0;
  paj7620ReadReg(0x43, 1, &data);
  switch(data){
    case GES_FORWARD_FLAG: npState = 1; lock_ms = 1500; break;
    case GES_BACKWARD_FLAG: npState = 0; lock_ms = 1500; break;
    case GES_LEFT_FLAG: if(npLevel < 1) npLevel += 0.1;lock_ms = 1500;break;
    case GES_RIGHT_FLAG: if(npLevel > 0) npLevel -= 0.1; lock_ms = 1500;break;
    case GES_UP_FLAG: 
                        if(npIdx < 5) npIdx++; 
                        else npIdx = 0;
                        lock_ms = 1500;
                        break;
    
    case GES_DOWN_FLAG: 
                        if(npIdx > 0) npIdx--; 
                        else npIdx = 5;
                        lock_ms = 1500;
                        break;
  }
  

  if(npState > 0){
    // put your main code here, to run repeatedly:
      for(int i=0;i<NUMPIXS;i++){
        // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
        myColor[0] = uint8_t(colorList[npIdx][0]*npLevel);
        myColor[1] = uint8_t(colorList[npIdx][1]*npLevel);
        myColor[2] = uint8_t(colorList[npIdx][2]*npLevel);
        pixels.setPixelColor(i, pixels.Color(myColor[0],myColor[1],myColor[2])); // Moderately bright green color.
      }
      pixels.show(); // This sends the updated pixel color to the hardware.
      //delay(500); // Delay for a period of time (in milliseconds).
  }
  else{
    pixels.clear();
    pixels.show();
  }
  
  delay(lock_ms);
  
}

Credits

meilily Li

meilily Li

14 projects • 48 followers
Love all things related to design and make.
Rain Ye

Rain Ye

2 projects • 10 followers
John Henry

John Henry

1 project • 2 followers
beginning
Kishor Maharjan

Kishor Maharjan

2 projects • 3 followers
Thanks to Anby Wen, CY, and Tao Ma.

Comments