This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projects:neopixel-bandwidth-room-light [2017-10-27 18:08] – trinitor | projects:neopixel-bandwidth-room-light [2017-12-23 11:49] (current) – [Motion detection notification] trinitor | ||
|---|---|---|---|
| Line 13: | Line 13: | ||
| **Light wars incoming!** | **Light wars incoming!** | ||
| - | The ESPP8266 | + | The ESP8266 |
| {{: | {{: | ||
| Line 68: | Line 68: | ||
| const int LEDPIN | const int LEDPIN | ||
| const int NUMPIXELS | const int NUMPIXELS | ||
| + | |||
| int displayrefresh | int displayrefresh | ||
| int shiftpixels | int shiftpixels | ||
| + | int alwaysoff | ||
| ////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////// | ||
| Line 79: | Line 81: | ||
| // echo " | // echo " | ||
| // echo " | // echo " | ||
| + | // echo " | ||
| + | // echo " | ||
| Line 107: | Line 111: | ||
| void loop() | void loop() | ||
| { | { | ||
| - | int red = 0; | + | int red |
| - | int green = 0; | + | int green |
| - | int blue | + | int blue = 0; |
| - | int refresh | + | int refresh |
| - | int scroll | + | int scroll |
| - | int pixel = 0; | + | int pixel |
| - | int all = 0; | + | int all |
| - | int clearall = 0; | + | int clearall |
| + | int effect | ||
| + | int option1 | ||
| | | ||
| int packetSize = Udp.parsePacket(); | int packetSize = Udp.parsePacket(); | ||
| Line 145: | Line 151: | ||
| all = json[" | all = json[" | ||
| clearall = json[" | clearall = json[" | ||
| - | scroll | + | scroll |
| + | effect | ||
| + | option1 | ||
| } | } | ||
| } | } | ||
| Line 197: | Line 205: | ||
| } | } | ||
| + | if (effect == 1) { | ||
| + | if (option1 == 0) { option1 = 128; } | ||
| + | fade(option1); | ||
| + | } | ||
| + | else if (effect == 2) { | ||
| + | if (option1 == 0) { option1 = 20; } | ||
| + | rainbow(option1); | ||
| + | } | ||
| // set color of Pixel | // set color of Pixel | ||
| // new color proviced color changed? | // new color proviced color changed? | ||
| - | if (red >0 || green >0 || blue >0) { | + | |
| //read current color | //read current color | ||
| uint32_t CurrentColor = pixels.getPixelColor(1); | uint32_t CurrentColor = pixels.getPixelColor(1); | ||
| Line 228: | Line 244: | ||
| if (shiftpixels == 2) { | if (shiftpixels == 2) { | ||
| uint32_t color = pixels.getPixelColor(1); | uint32_t color = pixels.getPixelColor(1); | ||
| - | pixels.setPixelColor(0, | + | |
| + | | ||
| + | } else { | ||
| + | pixels.setPixelColor(0, | ||
| + | } | ||
| } | } | ||
| } | } | ||
| Line 235: | Line 255: | ||
| delay(displayrefresh); | delay(displayrefresh); | ||
| + | } | ||
| + | |||
| + | // Effects | ||
| + | void fade(int maxBrightness){ | ||
| + | for(int brightness = 0; brightness < maxBrightness; | ||
| + | for(int i = 0; i < NUMPIXELS; i++ ) { | ||
| + | pixels.setPixelColor(i, | ||
| + | } | ||
| + | pixels.show(); | ||
| + | delay(5); | ||
| + | } | ||
| + | // Fade OUT | ||
| + | for(int brightness = maxBrightness; | ||
| + | for(int i = 0; i < NUMPIXELS; i++ ) { | ||
| + | pixels.setPixelColor(i, | ||
| + | } | ||
| + | pixels.show(); | ||
| + | delay(5); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void rainbow(uint8_t wait) { | ||
| + | uint16_t i, j; | ||
| + | |||
| + | for(j=0; j<256; j++) { | ||
| + | for(i=0; i < NUMPIXELS; i++) { | ||
| + | pixels.setPixelColor(i, | ||
| + | } | ||
| + | pixels.show(); | ||
| + | delay(wait); | ||
| + | } | ||
| + | for(int i=0; i< | ||
| + | pixels.setPixelColor(i, | ||
| + | } | ||
| + | pixels.show(); | ||
| + | } | ||
| + | |||
| + | uint32_t Wheel(byte WheelPos) { | ||
| + | WheelPos = 255 - WheelPos; | ||
| + | if(WheelPos < 85) { | ||
| + | return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3); | ||
| + | } | ||
| + | if(WheelPos < 170) { | ||
| + | WheelPos -= 85; | ||
| + | return pixels.Color(0, | ||
| + | } | ||
| + | WheelPos -= 170; | ||
| + | return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0); | ||
| } | } | ||
| </ | </ | ||
| Line 337: | Line 405: | ||
| </ | </ | ||
| + | |||
| + | ===== Webcam Motion Detection Notification ===== | ||
| + | You can use a RPi, a webcam and [[https:// | ||
| + | < | ||
| + | on_event_start echo " | ||
| + | on_event_end echo " | ||
| + | </ | ||