Last active
August 15, 2022 06:35
-
-
Save ledlogic/623d90999bad4012d1ee1ff21208dbaa to your computer and use it in GitHub Desktop.
A rendering for an eerie obelisk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN 1 | |
//single pixel, v2 Flora RGB NeoPixel, so GRB bitsream at 800 khz | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_GRB + NEO_KHZ800); | |
// assuming we have adafruit gemma v2 | |
// http://adafru.it/1222 | |
// assuming we have four fiora RGB neopixels | |
// http://adafru.it/1260 | |
// set current values | |
int gValues[] = {30, 20, 10, 0}; | |
// set current velocity | |
int gVelocity[] = {-10, 10, 10, 0}; | |
int delayMs = 300; | |
int delta = 1; | |
int gMax = 55; | |
int gMin = 0; | |
void setup() | |
{ | |
strip.begin(); | |
strip.show(); //initialize all pixels to off | |
} | |
// keep fading values in and out | |
void loop() | |
{ | |
updateValues(); | |
renderValues(); | |
delay(delayMs); | |
} | |
// update values | |
void updateValues() { | |
for (int i=0;i<4;i++) { | |
gValues[i] = gValues[i] + gVelocity[i]; | |
if (gValues[i] >= gMax) { | |
gVelocity[i] = -gVelocity[i]; | |
} | |
if (gValues[i] < gMin) { | |
gValues[i] = gMin; | |
gVelocity[i] = -gVelocity[i]; | |
} | |
} | |
} | |
// set green only, to current gValue for node | |
void renderValues() { | |
for (int i=0;i<4;i++) { | |
strip.setPixelColor(i,0,gValues[i],0); | |
} | |
strip.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment