Arduino Valentine’s Day Project: Romantic Wall Light

Arduino Valentine's Day Project: Romantic Wall Light Title

Somehow it should be Valentine’s Day every day, right? Special attention is due to the people who share their lives with us. How about a romantic wall light?

We need your consent to load the content of YouTube.

If you click on this video we will play the video, load scripts on your device, store cookies and collect personal data. This enables [Google Ireland Limited, Irland] to track activities on the Internet and to display advertising in a target group-oriented manner. There is a data transfer to the USA, which does not have EU-compliant data protection. You will find further information here.

Jmx0O2RpdiBjbGFzcz0mcXVvdDtudi1pZnJhbWUtZW1iZWQmcXVvdDsmZ3Q7Jmx0O2lmcmFtZSB0aXRsZT0mcXVvdDtBcmR1aW5vIFZhbGVudGluZSZyc3F1bztzIERheSBQcm9qZWN0OiBSb21hbnRpYyBXYWxsIExpZ2h0JnF1b3Q7IHdpZHRoPSZxdW90OzEyMDAmcXVvdDsgaGVpZ2h0PSZxdW90OzY3NSZxdW90OyBzcmM9JnF1b3Q7aHR0cHM6Ly93d3cueW91dHViZS5jb20vZW1iZWQvWTdtUGJSZFRKQnM/ZmVhdHVyZT1vZW1iZWQmcXVvdDsgZnJhbWVib3JkZXI9JnF1b3Q7MCZxdW90OyBhbGxvdz0mcXVvdDthY2NlbGVyb21ldGVyOyBhdXRvcGxheTsgY2xpcGJvYXJkLXdyaXRlOyBlbmNyeXB0ZWQtbWVkaWE7IGd5cm9zY29wZTsgcGljdHVyZS1pbi1waWN0dXJlJnF1b3Q7IGFsbG93ZnVsbHNjcmVlbiZndDsmbHQ7L2lmcmFtZSZndDsmbHQ7L2RpdiZndDs=

This Arduino project is a heart with milled or printed names on it. Underneath is a WS2812 LED strip that glows to the outside and gives the heart a glow effect. You can of course decide for yourself how big the heart will be, or how many LEDs you want to use. But make sure that the electronics have enough space underneath. The heart is equipped with a button with which different animations can be switched through. All of this is operated using a USB power supply.

Components

  • 1x Arduino Uno*
  • 1x WS2812 LED light strip*
  • 1x USB power supply and white USB cable
  • 1x electrolytic capacitor 500 – 1000 uF, 16V
  • 1x resistor 470 Ohm (there is also a resistance value nearby)

Circuit Diagram

Arduino Valentine's Day Project: Romantic Wall Light Circuit

The circuit consists of two circuits. The first circuit connects the WS2812 LEDs to the GND and 5V + of the Arduino board. These two connections are also connected via an electrolytic capacitor. You would have to say “not connected” correctly, since the capacitor does not establish an electrical connection. It stores energy that is emitted when the LEDs e.g. need a lot of energy when changing colors (back-up capacitor). The data-in connection of the LED strip is connected to the digital pin 6 of the Arduino board via a resistor (470 ohms or close). The second circuit consists of a button that is connected to the GND and the digital pin 2 of the Arduino.

I have more information about the WS2812 LEDs for you here: Arduino WS2812 – The easiest way to control many LEDs with Arduino

Building Plan

Arduino Valentine's Day Project: Romantic Wall Light Plan

I chose a classic heart with engraved names, but you can also stick photos on the heart. There are endless possibilities, so let your imagination run wild. Whether you make it from wood, cardboard, paper or other materials is also entirely up to you.

Arduino Valentine's Day Project: Romantic Wall Light Building Plan

It is important that you leave space for the electronics. Since the LEDs are supposed to shine indirectly on the wall behind, I hide them behind the heart.

Code

The Arduino program is a sample code from the Adafruit Nanopixel library. Incidentally, this must be installed in the Arduino software. To do this, open the Sketch> Embed Libraries> Manage Libraries … menu in the Arduino IDE (software) and search for NeoPixel in the search field. Install the latest version of the Adafruit NeoPixel library from Adafruit. Now open the example under File> Examples> Adafruit NeoPixel> ButtonCycler. Change the number of pixels in the line:

define PIXEL_COUNT 25 // Number of NeoPixels

Transfer the program to the Arduino board. That’s it already 🙂

The code plays different animations. In the beginning everything is over. If the button is pressed, the counter of the variable mode changes. The value of these variables determines the current animation through the switch case query.

// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 60

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)


// setup() function -- runs once at startup --------------------------------

void setup() {
  // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(255,   0,   0), 50); // Red
  colorWipe(strip.Color(  0, 255,   0), 50); // Green
  colorWipe(strip.Color(  0,   0, 255), 50); // Blue

  // Do a theater marquee effect in various colors...
  theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
  theaterChase(strip.Color(127,   0,   0), 50); // Red, half brightness
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue, half brightness

  rainbow(10);             // Flowing rainbow cycle along the whole strip
  theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
}


// Some functions of our own for creating animated effects -----------------

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
// between frames.
void theaterChase(uint32_t color, int wait) {
  for(int a=0; a<10; a++) {  // Repeat 10 times...
    for(int b=0; b<3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in steps of 3...
      for(int c=b; c<strip.numPixels(); c += 3) {
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show(); // Update strip with new contents
      delay(wait);  // Pause for a moment
    }
  }
}

// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
void rainbow(int wait) {
  // Hue of first pixel runs 5 complete loops through the color wheel.
  // Color wheel has a range of 65536 but it's OK if we roll over, so
  // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
  // means we'll make 5*65536/256 = 1280 passes through this outer loop:
  for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
    for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
      // Offset pixel hue by an amount to make one full revolution of the
      // color wheel (range of 65536) along the length of the strip
      // (strip.numPixels() steps):
      int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
      // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
      // optionally add saturation and value (brightness) (each 0 to 255).
      // Here we're using just the single-argument hue variant. The result
      // is passed through strip.gamma32() to provide 'truer' colors
      // before assigning to each pixel:
      strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
    }
    strip.show(); // Update strip with new contents
    delay(wait);  // Pause for a moment
  }
}

// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
void theaterChaseRainbow(int wait) {
  int firstPixelHue = 0;     // First pixel starts at red (hue 0)
  for(int a=0; a<30; a++) {  // Repeat 30 times...
    for(int b=0; b<3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in increments of 3...
      for(int c=b; c<strip.numPixels(); c += 3) {
        // hue of pixel 'c' is offset by an amount to make one full
        // revolution of the color wheel (range 65536) along the length
        // of the strip (strip.numPixels() steps):
        int      hue   = firstPixelHue + c * 65536L / strip.numPixels();
        uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show();                // Update strip with new contents
      delay(wait);                 // Pause for a moment
      firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
    }
  }
}

1 thought on “Arduino Valentine’s Day Project: Romantic Wall Light”

  1. Pingback: Arduino WS2812 - The easiest way to control many LEDs with Arduino

Leave a Reply

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