In the last halloween I decided to create a project for the season. Using a 3D model of a ghost that i printed on the Prusa i3 and the Cheerlights project i created a Halloween decoration that changes color randomly.
The Cheerlight project is an open-source project that synchronizes all light devices that use’s it. Through Twitter, using the #cheerlight hashtag, we chose a color from the Cheerlights project color palette. All devices that are connected to the project Cheerlights read the color through the api and change their color to that. Through a tweet it is possible to change the colors of all the devices of the planet connected to the project.
Materials
Tools
- 3D Printer
- Soldering iron
3D Model
Assembly
First it was necessary to create the support for the connections. This was created using a protoboard, female sockets for the ESP-01 and solder. The female sockets allow to easily remove the ESP-01 for use in another project or to replace it in case of failure. The solder was used to fix the components and create connecting tracks. The protoboard comes pre-drilled and with connections around each hole. It is only necessary to fix the components and join the various holes to create the tracks.
Then the battery holder was soldered. At the same time, the base that will houses the components was printed. This consists of a square base, with enough space to house the various components, a led ring opening and enough space for the printed ghost.
After the base was ready, the led ring was installed and connected to the support of the remaining components. The support and the battery holder were fixed to the base with thermal glue.
Code
Next it was prepared the code is loaded for the ESP-01.
The code will connect the ESP-01 to the wireless network and then connect to the cheerlight project and check the current color. It then changes its color to the color of the cheerlight project.
For the code to work, three libraries are required:
- ThingSpeak – to connect to Cheerlights project
- ESP8266WiFi – to use the ESP-01
- Adafruit_NeoPixel – to use the led ring
#include <ThingSpeak.h> #include <ESP8266WiFi.h> #include <Adafruit_NeoPixel.h> #define PixelPin 2 #define PixelNum 12 const char* ssid = "<SSID>"; const char* password = "<SSID PASSWORD>"; unsigned long cheerLightsChannelNumber = 1417; int delayval = 500; String colorName[] = {"none","red","pink","green","blue","cyan","white","warmwhite","oldlace","purple","magenta","yellow","orange"}; // Map of RGB values for each of the Cheerlight color names int colorRGB[][3] = { 0, 0, 0, // "none" 255, 0, 0, // "red" 255,192,203, // "pink" 0,255, 0, // "green" 0, 0,255, // "blue" 0,255,255, // "cyan", 255,255,255, // "white", 255,223,223, // "warmwhite", 255,223,223, // "oldlace", 128, 0,128, // "purple", 255, 0,255, // "magenta", 255,255, 0, // "yellow", 255,165, 0}; // "orange"}; Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PixelNum, PixelPin, NEO_GRB + NEO_KHZ800); WiFiClient wclient; void setup() { Serial.begin(9600); WiFi.begin(ssid, password); WiFi.mode(WIFI_STA); Serial.println("."); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Ligado a "); Serial.println(ssid); Serial.print("Endereço IP: "); Serial.println(WiFi.localIP()); pixels.begin(); ThingSpeak.begin(wclient); } void loop() { String color = ThingSpeak.readStringField(cheerLightsChannelNumber, 1); setColor(color); delay(5000); } void setColor(String color) { for(int iColor = 0; iColor <= 12; iColor++) { if(color == colorName[iColor]) { for(int i=0;i<PixelNum;i++){ pixels.setPixelColor(i, pixels.Color(colorRGB[iColor][0],colorRGB[iColor][1],colorRGB[iColor][2])); // Moderately bright green color. pixels.show(); // This sends the updated pixel color to the hardware. } return; } } }
You can find all the code at my GitHub Account
The ghost was printed on the Prusa i3 using transparent PLA to allow the passage of light.
Finally the battery was installed and the ghost placed.
Sendind a tweet with “#cheerlight red” switch the color to red.
Comments are closed.