josueo10
Published

LamPixel

The ultimate lamp.

IntermediateShowcase (no instructions)216
LamPixel

Things used in this project

Hardware components

NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
DC-DC Buck (Step Down) Regulator, Adjustable
DC-DC Buck (Step Down) Regulator, Adjustable
×1
60W PCIe 12V 5A Power Supply
Digilent 60W PCIe 12V 5A Power Supply
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Tape, Electrical
Tape, Electrical
Scissor, Electrician
Scissor, Electrician
Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

Tinkercad Diagram

Code

LamPixel Code

C/C++
Code used for Arduino Uno, langauge: C++
#include <Adafruit_NeoPixel.h>

#define NUMPIXELS      16 // number of neopixels in strip

#define PIN 2   // input pin Neopixel is attached to

#include <LiquidCrystal_I2C.h>



LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

 


int delayval = 1000; // timing delay in milliseconds

int redColor = 0;
int greenColor = 0;
int blueColor = 0;

int buttonState = 0;
int buttoncounter = 0;

void setup() {
  // Initialize the NeoPixel library.
  pixels.begin();

  lcd.init();
  lcd.clear();        
  lcd.backlight();      // Make sure backlight is on


 
}

void loop() {
  do {

    buttonState = digitalRead(13);

    if (buttonState == HIGH){ // If button is pushed, alert user
      buttoncounter++;
    }

  } while (buttonState == LOW);

  Serial.println("Button was pushed");

  do {

    buttonState = digitalRead(13);

 
  Serial.println("Button was released");
  Serial.println(buttoncounter);

  } while (buttonState == HIGH); // Once button is released, alert user

  if (buttoncounter == 1){
   
   for (int i=0; i < NUMPIXELS; i++) { // switch all of them to red
   pixels.setPixelColor(i, pixels.Color(255, greenColor, blueColor));

   lcd.setCursor(3,0);   //Set cursor to character 2 on line 0
  lcd.print(" Hello!");

     
   }
 
   pixels.show();
   delay(100);
  }
   
  else if (buttoncounter == 2){
   
   for (int i=0; i < NUMPIXELS; i++) { // switch all of them to red
   pixels.setPixelColor(i, pixels.Color(redColor, 255, blueColor));
     
   }
   
    pixels.show();
   delay(100);
  }
   
    else if (buttoncounter == 3){
   
   for (int i=0; i < NUMPIXELS; i++) { // switch all of them to red
   pixels.setPixelColor(i, pixels.Color(redColor, greenColor, 255));
     
   }
   
    pixels.show();
   delay(100);
   
    }

    else if (buttoncounter == 4){
      for (int i=0; i < NUMPIXELS; i++) { // switch all of them to red
   pixels.setPixelColor(i, pixels.Color(255, greenColor, blueColor));
   
  }
 
  pixels.show();
   
    delay(delayval);

   for (int i=0; i < NUMPIXELS; i++) { // switch all of them to green
   pixels.setPixelColor(i, pixels.Color(redColor, 255, blueColor));

}
      pixels.show();
   
    delay(delayval);
 
  for (int i=0; i < NUMPIXELS; i++) { // switch all of them to blue
   pixels.setPixelColor(i, pixels.Color(redColor, greenColor, 255));
   
  }
      pixels.show();
   
    delay(delayval);
     
    }

  else {
    buttoncounter = 0;
       // setColor();      // Aquire color sent to Arduino
    pixels.clear();  // Clear off all pixels to clear/0
    pixels.show();   // Show all the pixels their "clear" color...
    lcd.clear();
  }
   
}
 

Credits

josueo10
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.