Leuchtender Weihnachtsstern Hack

Hard to believe, but Christmas is getting closer. The Christmas holiday is just before and you want, of course, in your free time a bit of the hobby Maker Afterprecy. What is there better than to implement as a small IKEA hack. Today we want to modify the IKEA lampshade Stråla somewhat and to reciprocate to an illustrative window decoration.

Video at the end of the blog!

Required hardware and software

The hardware for this experimental setup is relatively simple, see Table 1.

Pos

Quantity

Component

link

1

1

Nano V3.0 CH340

https://az-delivery.de

2

1

Breadboard, best as a kit

https://az-delivery.de

3

1

LED ring 5V RGB WS2812B 12-bit 37mm

https://az-delivery.de

4

1

Battery clip 9-volt I-type clip snap

https://az-delivery.de

5 1 MB-102 power supply adapter https://az-delivery.de

Table 1: Hardware parts for Cyclone with WS2812B LED ring

In addition, you still need a 9V blockbate, so that later the hack gets electricity. For the hack, I specifically designed a small case for the 3D printer, but you can also make your own housing with a bit of cardboard and glue.

In addition, you still have to deal with IKEA Lampshade Stråla Organize because it's about the hack just this lampshade.

The required software for this project is manageable:

The structure

The circuit for the small IKEA hack should be compact, but functional, see Figure 1.

Figure 1: Construction of the circuit

Figure 1: Construction of the circuit

Please keep in mind that the LED ring needs a 5V voltage disposal. The mass of Nano V3.0 should be coupled to the LED ring.

The source code

As you are used to it, the source code is again provided with many comments, see code 1. At the same time this is designed in the loop function so that you can add more lighting animations.

Sketch download

 //-----------------------------------------------------
// IKEA Star Hack for Nano V3.0
// Author: Joern Way
// License: GNU GPL 3.0
// Created: 07. Dec. 2021
// update:
//-----------------------------------------------------
// Include Libraries
#include

// definite
#define led_pin 6 // Pin on Arduino Nano D6
#define led_count 12 // Num of LEDs
#define time_change 120000 // Time to Switch Fashion in MS 2 min = 120000ms
#define num_mode 5 // Max Num of LED modes

// Init Neopixel Strip
Adafruit_neaopixel strip(LED_count, LED_PIN, Neo_grb + Neo_khz800); // init LED ring

// Some Global Vars
int IshowMode = -1; // Change to Valid Mode to get a fix mode !!
int IcurrentMode = 0; // to Switch Through the Modes
unsigned long ullastime = 0; // for time-checking

/*
=================================================================
FUNCTION: Setup
RETURNS: Void
Description: Needed Setup Routine for Microcontroller
=================================================================
*/
void set up() {
Serial.Begin(115200);
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)
randomseed(analogead(A0)); // Make Random More Randome

}

/*
=================================================================
FUNCTION: Loop
RETURNS: Void
Description: Needed Loop Routine for Microcontroller
=================================================================
*/
void loop() {
IF(IshowMode == -1)
{
IF(IcurrentMode >= NUM_MODE)
IcurrentMode = 0;
Serial.Println("Current Mode:" + String(IcurrentMode));
}
Else
IcurrentMode = IshowMode;

// Simple State Machine to Go Through the Modes
// More Modes Can Be Add, Keep in Mind to Increase Num_Mode
switch(IcurrentMode)
{
Case 0:
Serial.Println("Case: 0");
randomcolor();
brew;
Case 1:
Serial.Println("Case: 1");
rainbow(10);
brew;
Case 2:
Serial.Println("Case: 2");
theaterChaseRainbow(50);
break;
case 3:
Serial.println("Case: 3");
theaterChase(strip.Color(random(0,255), random(0,255), random(0,255)),250);
break;
case 4:
Serial.println("Case: 4");
shift(150);
break;
default:
Serial.println("Case: default");
randomColor();
break;
}
}

/*
=================================================================
Function: randomColor
Returns: void
Description: Color a random LED with a random color
=================================================================
*/
void randomColor()
{
static unsigned long ulRandomLast = millis();
ulLastTime = millis();
Serial.println("ulLastTime: " + String(ulLastTime));
strip.clear();
while((millis() - ulLastTime) < TIME_CHANGE)
{
if(millis() - ulRandomLast > 250)
{
int iRed = random(0,255);
int iGreen = random(0,255);
int iBlue = random(0,255);
int iLED = random(0,int(LED_COUNT) );
strip.setPixelColor(iLED, strip.Color(iRed, iGreen, iBlue)); // Set pixel's color (in RAM)
strip.show();
ulRandomLast = millis();
}
}
Serial.println("Exit while-loop");
iCurrentMode++;
}

/*
=================================================================
Function: rainbow
Returns: void
IN wait: Time to wait for next LED change
Description: Color the ring like a rainbow
=================================================================
*/
void rainbow(int wait)
{
static unsigned long ulRainbowLast = millis();
ulLastTime = millis();
Serial.println("ulLastTime: " + String(ulLastTime));
static int iFirstPixelHue = 0;
strip.clear();
while((millis() - ulLastTime) < TIME_CHANGE)
{
if(millis() - ulRainbowLast > wait)
{
iFirstPixelHue += 256;
if(iFirstPixelHue >= 65536)
iFirstPixelHue = 0;
for(int i=0; i<strip.numPixels(); i++)
{
int iPixelHue = iFirstPixelHue + (i / strip.numPixels());
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(iPixelHue)));
}
ulRainbowLast = millis();
strip.show();
}
}
Serial.println("Exit while-loop");
iCurrentMode++;
}

/*
=================================================================
Function: theaterChaseRainbow
Returns: void
IN wait: Time to wait for next LED change
Description: Circle rainbow-color around the LED-ring
=================================================================
*/
void theaterChaseRainbow(int wait)
{
static unsigned long theaterChaseRainbow = millis();
ulLastTime = millis();
Serial.println("ulLastTime: " + String(ulLastTime));
static int iFirstPixelHue = 0;
strip.clear();
static int iFirstPixel = 0;
while((millis() - ulLastTime) < TIME_CHANGE)
{
if(millis() - theaterChaseRainbow > wait)
{
strip.clear();
for(int iCount = iFirstPixel; iCount < strip.numPixels(); iCount += 3)
{
int hue = iFirstPixelHue + iCount * 65536L / strip.numPixels();
uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
strip.setPixelColor(iCount, color); // Set pixel 'c' to value 'color'
}
theaterChaseRainbow = millis();
strip.show();
iFirstPixelHue += 65536 / 90;
iFirstPixel++ ;
if(iFirstPixel >= 3)
iFirstPixel = 0;
}
}
Serial.println("Exit while-loop");
iCurrentMode++;
}

/*
=================================================================
Function: theaterChase
Returns: void
IN wait: Time to wait for next LED change
IN color: Random color for the LED-Ring
Description: Circle random-color around the LED-ring
=================================================================
*/
void theaterChase(uint32_t color, int wait)
{
static unsigned long theaterChase = millis();
ulLastTime = millis();
Serial.println("ulLastTime: " + String(ulLastTime));
static int iFirstPixel;
iFirstPixel = 0;
strip.clear();
while((millis() - ulLastTime) < TIME_CHANGE)
{
if(millis() - theaterChase > wait)
{
strip.clear();
for(int iCount = iFirstPixel; iCount < strip.numPixels(); iCount += 3)
{
strip.setPixelColor(iCount, color); // Set pixel 'c' to value 'color'
}
theaterChase = millis();
strip.show();
iFirstPixel++ ;
if(iFirstPixel >= 3)
iFirstPixel = 0;
}
}
Serial.println("Exit while-loop");
iCurrentMode++;
}

/*
=================================================================
Function: shift
Returns: void
IN wait: Time to wait for next LED change
Description: Color each LED-ring step by step to random color
=================================================================
*/
void shift(int wait)
{
static unsigned long ulShift = millis();
ullastime = millis();
Serial.Println("UlLastTime" + String(ullastime));
static int Ipixel;
Ipixel = 0;
static int iShifter = 1;
strip.Clear();
static uint32_t color = strip.Color(random(0,255), random(0,255), random(0,255));
while((millis() - ullastime) < TIME_CHANGE)
{
IF(millis() - ulShift > wait)
{
strip.setPixelColor(Ipixel, color); // Set pixel 'c' to value 'color'
ulShift = millis();
strip.show();

Ipixel+= iShifter;
IF(Ipixel >= (LED_count - 1) )
{
color = strip.Color(random(0,255), random(0,255), random(0,255));
iShifter = -1;
}
Else IF (Ipixel <= 0)
{
iShifter = 1;
color = strip.Color(random(0,255), random(0,255), random(0,255));
}
}
}
Serial.Println("Exit while-loop");
IcurrentMode++;
}
Code 1: Code for poinsettia Hack

 

Take for example, the function further light animations random color ()That just shows the principle of animation. Since I am personally not a fan of the function delay (), I use a subtraction of the currently running milliseconds to the last stored value. If a limit is exceeded, the function continues to run or started a new light animation. The delay () function blocks the program, thereby preventing a liquid execution, if you want to respond to events.

assembly

Thus the star at the end lights up accordingly, I have specially designed still a small housing, as shown in Figure 2. The housing can be found on my GitHubPage so that you can slicing it yourself.

Housing

Figure 2: housing for the technique

Since I unfortunately did not have appropriate screws for attaching the LED ring, it did a good amount of hot glue to this point. In connection still the case with the holder of the star join, for example, simply with cable ties and ready is the shining star, see Figure. 3

The finished star

Figure 3: The final Star

Overall, the assembly takes without printing the housing, about 30 minutes. With a bit of craft Talent own housing made of cardboard is crafted for the technology quickly.

summary

I wish you a Merry Christmas and a Merry Christmas. Although Corona has us still under control, it should not slow down but the maker drive. As mentioned in the source code, you have the ability to add your own effects, or simply to leave everything like that. Are also conceivable LED tubes that are wrapped around a housing. Everything is possible, let your creativity run wild.

 

Other projects for AZ-delivery by me, see
https://github.com/M3taKn1ght/Blog-Repo.

 

For arduinoProjects for beginners

4 comments

Andreas Wolter

Andreas Wolter

@Claude Wiltzius: danke für den Hinweis. Ich habe das an Jörn Weise weitergegeben. Er überprüft das.

Grüße,
Andreas Wolter
AZ-Delivery Blog

Claude Wiltzius

Claude Wiltzius

Hallo Jürgen Weise,
Top Beitrag, problemlos als Neuling nachgebaut !!!
Leider finde ich die Datei zum 3D Druck des Gehäuses nicht auf Ihrer GitHub-Seite ?
könnte ich diese vielleicht per Mail haben ?
vielen Dank und guten Rutsch !
Claude

J. Weise

J. Weise

Hallo,
Tatsächlich nutze ich den folgenden Schirm https://www.ikea.com/de/de/p/strala-leuchtenschirm-spitze-weiss-20502883/
Interessant, dass das Möbelhaus hier den Link verändert hat, will ich zuvor über den Oberen Link noch den Lampenschirm erwerben konnte.
Weise

Jürgen

Jürgen

Sehr geehrter Herr Jörn Weise,
ich finde Ihren Beitrag sehr interessant und man hat die Möglichkeit mit dem Code zu spielen um noch andere Effekte zu erzeugen.
Das einzige was ich vermisst habe ist die Angabe zum Durchmesser des Sternes.
Der Link zu IKEA zeigt auf einen Lampenschirmfuß und nicht auf einen Stern. Darunter sind zwar Sterne abgebildet, jedoch mit unterschiedlichen Durchmessern.
Welchen Durchmesser bzw. Stern, haben Sie für dieses Projekt verwendet ?
Würde mich über eine Antwort sehr freuen.
Mit freundlichen Grüßen
Jürgen

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN