Skip to content

Instantly share code, notes, and snippets.

@houhr
Last active September 11, 2020 08:21
Show Gist options
  • Select an option

  • Save houhr/8d0593ca03132c88bf48 to your computer and use it in GitHub Desktop.

Select an option

Save houhr/8d0593ca03132c88bf48 to your computer and use it in GitHub Desktop.
//Download Adafruit_NeoPixel.h here: https://github.com/adafruit/Adafruit_NeoPixel
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 1
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() {
pixels.begin(); // This initializes the NeoPixel library.
pixels.setBrightness(100);
}
void loop() {
for (int i = 0; i <= 255; i++) {
for (int j = 0; j <= 255; j++) {
for(int k = 0; k<=255; k++) {
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(0, pixels.Color(i,j,k)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
}
}
@ScaredyCat
Copy link
Copy Markdown

I appreciate this is old but just in case anyone else finds it:

Just use:

pixels.setPixelColor(pixelNumber, colour);

That way you can set individual pixels regardless of the number you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment