Created
September 20, 2020 15:19
-
-
Save rdeprey/99130ee7d46371e4a359ad70619c21e5 to your computer and use it in GitHub Desktop.
C++ Code to Set HalloWing M4 NeoPixel Colors
This file contains 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
#if 1 // Change to 1 to enable this code (must enable ONE user*.cpp only!) | |
#include <Adafruit_NeoPixel.h> // Imports the NeoPixel library | |
#define LED_PIN 8 // The NeoPixels are on Port 8 | |
#define LED_COUNT 4 // There are 4 NeoPixels on the board | |
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); | |
void user_setup(void) { | |
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) | |
} | |
long currentPixelHue = 0; | |
int purple = 51000; | |
int orange = 8922; | |
int prev; | |
void set_colors(void) { | |
for(int i=0; i<strip.numPixels(); i++) { | |
// Set every other NeoPixel to either purple or orange | |
if (prev == orange) { | |
prev = purple; | |
currentPixelHue = purple; | |
} else { | |
prev = orange; | |
currentPixelHue = orange; | |
} | |
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(currentPixelHue))); // Sets individual NeoPixel color | |
} | |
strip.show(); // Update strip with new colors | |
} | |
void user_loop(void) { | |
set_colors(); | |
} | |
#endif // 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment