Acrylic panels illuminated with led lights
A perfect Christmas present
Components and supplies
1
Capacitor 100 µF
1
Arduino Nano R3
1
Resistor 330 ohm
2
Pushbutton Switch, Pushbutton
1
Breadboard (generic)
1
Industrial Pushbutton Switch, Off-On
2
Resistor 10k ohm
Tools and machines
1
Soldering iron (generic)
1
Laser cutter (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Acryl Sign
arduino
1/* 2 3Acryl Sign 4 by smi1100 - 12/09/2022 5 6pins: 7 LED: 6 8 Buttons: 8, 9 9 10libraries: 11 - Adafruit_NeoPixel.h 12 13*/ 14 15 16#include <Adafruit_NeoPixel.h> 17#define LED_PIN 6 // Which pin on the Arduino is connected to the NeoPixels? 18#define LED_COUNT 8 // How many NeoPixels are attached to the Arduino? 19Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); 20 21const int buttonPin_front = 8; 22boolean oldButtonState_front = HIGH; 23boolean newButtonState_front; 24int strip_color_front = 1; 25 26const int buttonPin_back = 9; 27boolean oldButtonState_back = HIGH; 28boolean newButtonState_back; 29int strip_color_back = 1; 30 31void setup() 32{ 33 Serial.begin(9600); 34 strip.begin(); 35 strip.show(); 36 strip.setBrightness(255); // Set BRIGHTNESS to about 1/5 (max = 255) 37 38 pinMode(buttonPin_front, INPUT_PULLUP); 39 pinMode(buttonPin_back, INPUT_PULLUP); 40 41 Serial.println("Setup complete"); 42 Serial.println(""); 43 delay(500); 44} 45 46void loop() 47{ 48 newButtonState_front = digitalRead(buttonPin_front); 49 50 if((newButtonState_front == LOW) && (oldButtonState_front == HIGH)) // Button not pressed = LOW 51 { 52 delay(20); // Short delay to debounce button. 53 newButtonState_front = digitalRead(buttonPin_front); // Check if button is still low after debounce. 54 55 if(newButtonState_front == LOW) // Yes, still low 56 // einschalten (new = 0, old = 1) 57 // zu Beginn wird die if Schleife aktiviert und die erste Farbe angezeigt 58 // am Ende der Schleife old = new (new = 0, old = 0) 59 // Knopf gedrckt (if Schleife nicht durchlaufen (new = 1, old = 0) 60 // am Ende der Schleife old = new (new = 1, old = 1) - if Schleife nicht durchlaufen 61 // Knopf loslassen(new = 0, old = 1) -> If Schleife durchlaufen, Farbe ndert sich 62 { 63 if(strip_color_front > 8) strip_color_front = 1; 64 Serial.print("strip color front number: "); Serial.println(strip_color_front); 65 switch (strip_color_front) 66 { 67 case 1: 68 Serial.println("Strip color front RED"); 69 Serial.println(""); 70 for (int i = 0; i <= 3;i++) 71 { 72 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 73 } 74 strip.show(); 75 break; 76 77 case 2: 78 Serial.println("Strip color front GREEN"); 79 Serial.println(""); 80 for (int i = 0; i <= 3;i++) 81 { 82 strip.setPixelColor(i, 0, 255, 0); //strip.setPixelColor(n, red, green, blue); 83 } 84 strip.show(); 85 break; 86 87 case 3: 88 Serial.println("Strip color front BLUE"); 89 Serial.println(""); 90 for (int i = 0; i <= 3;i++) 91 { 92 strip.setPixelColor(i, 0, 0, 255); //strip.setPixelColor(n, red, green, blue); 93 } 94 strip.show(); 95 break; 96 97 case 4: 98 Serial.println("Strip color front WHITE"); 99 Serial.println(""); 100 for (int i = 0; i <= 3;i++) 101 { 102 strip.setPixelColor(i, 255, 255, 255); //strip.setPixelColor(n, red, green, blue); 103 } 104 strip.show(); 105 break; 106 107 case 5: 108 Serial.println("Strip color front PINK"); 109 Serial.println(""); 110 for (int i = 0; i <= 3;i++) 111 { 112 strip.setPixelColor(i, 255, 20, 147); //strip.setPixelColor(n, red, green, blue); 113 } 114 strip.show(); 115 break; 116 117 case 6: 118 Serial.println("Strip color front YELLOW"); 119 Serial.println(""); 120 for (int i = 0; i <= 3;i++) 121 { 122 strip.setPixelColor(i, 255, 215,0); //strip.setPixelColor(n, red, green, blue); 123 } 124 strip.show(); 125 break; 126 127 case 7: 128 Serial.println("Strip color front rainbow"); 129 Serial.println(""); 130 for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) 131 { 132 strip.rainbow(firstPixelHue); 133 strip.show(); 134 Serial.print("firstPixelHue: ");Serial.println(firstPixelHue); 135 delay(10); 136 if (firstPixelHue == 327168) firstPixelHue = 0; 137 138 newButtonState_front = digitalRead(buttonPin_front); 139 newButtonState_back = digitalRead(buttonPin_back); 140 if(newButtonState_front == HIGH || newButtonState_back == HIGH) 141 { 142 for (int i = 0; i <= 3;i++) 143 { 144 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 145 } 146 strip.show(); 147 148 for (int i = 4; i <= 7;i++) 149 { 150 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 151 } 152 strip.show(); 153 strip_color_back = 1; 154 155 break; 156 } 157 } 158 break; 159 160 161 case 8: 162 Serial.println("Strip color front color wipe"); 163 Serial.println(""); 164 int stopper = 0; 165 while (stopper == 0) 166 { 167 Serial.print("Stopper: ");Serial.println(stopper); 168 for(int i=0; i<strip.numPixels(); i++) 169 { 170 strip.setPixelColor(i, 255, 0, 0); 171 strip.show(); 172 newButtonState_front = digitalRead(buttonPin_front); 173 newButtonState_back = digitalRead(buttonPin_back); 174 if(newButtonState_front == HIGH || newButtonState_back == HIGH) 175 { 176 stopper = 1; 177 break; 178 } 179 delay(200); 180 } 181 182 for(int i=0; i<strip.numPixels(); i++) 183 { 184 strip.setPixelColor(i, 0, 255, 0); 185 strip.show(); 186 newButtonState_front = digitalRead(buttonPin_front); 187 newButtonState_back = digitalRead(buttonPin_back); 188 if(newButtonState_front == HIGH || newButtonState_back == HIGH) 189 { 190 stopper = 1; 191 break; 192 } 193 delay(200); 194 } 195 196 for(int i=0; i<strip.numPixels(); i++) 197 { 198 strip.setPixelColor(i, 0, 0, 255); 199 strip.show(); 200 newButtonState_front = digitalRead(buttonPin_front); 201 newButtonState_back = digitalRead(buttonPin_back); 202 if(newButtonState_front == HIGH || newButtonState_back == HIGH) 203 { 204 stopper = 1; 205 break; 206 } 207 delay(200); 208 } 209 210 211 } 212 for (int i = 0; i <= 3;i++) 213 { 214 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 215 } 216 strip.show(); 217 218 for (int i = 4; i <= 7;i++) 219 { 220 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 221 } 222 strip.show(); 223 strip_color_back = 1; 224 225 226 break; 227 228 } // end of switch 229 230 strip_color_front++; 231 } 232 233 } 234 oldButtonState_front = newButtonState_front; 235 236 237 newButtonState_back = digitalRead(buttonPin_back); 238 239 if((newButtonState_back == LOW) && (oldButtonState_back == HIGH)) 240 { 241 delay(20); 242 newButtonState_back = digitalRead(buttonPin_back); 243 244 if(newButtonState_back == LOW) 245 { 246 if(strip_color_back > 6) strip_color_back = 1; 247 Serial.print("strip color back number: "); Serial.println(strip_color_back); 248 switch (strip_color_back) 249 { 250 case 1: 251 Serial.println("Strip color back RED"); 252 Serial.println(""); 253 for (int i = 4; i <= 7;i++) 254 { 255 strip.setPixelColor(i, 255, 0, 0); //strip.setPixelColor(n, red, green, blue); 256 } 257 strip.show(); 258 break; 259 260 case 2: 261 Serial.println("Strip color back GREEN"); 262 Serial.println(""); 263 for (int i = 4; i <= 7;i++) 264 { 265 strip.setPixelColor(i, 0, 255, 0); //strip.setPixelColor(n, red, green, blue); 266 } 267 strip.show(); 268 break; 269 270 case 3: 271 Serial.println("Strip color back BLUE"); 272 Serial.println(""); 273 for (int i = 4; i <= 7;i++) 274 { 275 strip.setPixelColor(i, 0, 0, 255); //strip.setPixelColor(n, red, green, blue); 276 } 277 strip.show(); 278 break; 279 280 case 4: 281 Serial.println("Strip color back WHITE"); 282 Serial.println(""); 283 for (int i = 4; i <= 7;i++) 284 { 285 strip.setPixelColor(i, 255, 255, 255); //strip.setPixelColor(n, red, green, blue); 286 } 287 strip.show(); 288 break; 289 290 case 5: 291 Serial.println("Strip color back PINK"); 292 Serial.println(""); 293 for (int i = 4; i <= 7;i++) 294 { 295 strip.setPixelColor(i, 255, 20, 147); //strip.setPixelColor(n, red, green, blue); 296 } 297 strip.show(); 298 break; 299 300 case 6: 301 Serial.println("Strip color back YELLOW"); 302 Serial.println(""); 303 for (int i = 4; i <= 7;i++) 304 { 305 strip.setPixelColor(i, 255, 215,0); //strip.setPixelColor(n, red, green, blue); 306 } 307 strip.show(); 308 break; 309 } 310 strip_color_back++; 311 } 312 } 313 oldButtonState_back = newButtonState_back; 314} 315 316void colorWipe(uint32_t color, int wait) 317{ 318 for(int i=0; i<strip.numPixels(); i++) 319 { 320 strip.setPixelColor(i, color); 321 strip.show(); 322 delay(wait); 323 } 324} 325
Downloadable files
acryl_sign_1SqxKJ8MaD.fzz
acryl_sign_1SqxKJ8MaD.fzz
Comments
Only logged in users can leave comments