Velleman VM207 User Manual - page 11
11
K8403
USER MANUAL
Next, we have the main loop function:
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pix-
els minus one.
for(int i=0;i // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 pixels.setPixelColor(i, pixels.Color(0,150,0)); // 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). } } This is where the magic happens. The loop function repeats itself every time, and inside that loop function there is a for-loop that will execute these lines every half a second: pixels.setPixelColor(i, pixels.Color(0,0,255)); // Bright blue color. pixels.show(); // This sends the updated pixel color to the hardware. delay(delayval); // Delay for a period of time (in milliseconds). The first line will give the pixel at the place that is stored in value “i” a green color, but the panel will only be updated with this information when the second line “pixels.show” has been called. Since these two lines get called every 500 ms and i always increases with 1 (wonder why this is so? Read here: https://www.arduino.cc/ en/reference/for about how for-loops work) you can see that the panel should slowly fill up with green LEDs when you run this code on an Arduino. Let’s try that, compile and upload the code to your Arduino and hook everything up. You should see the panel slowly (every 500 ms) light up with one more green LED. You will also notice that once the panel has filled up with green pixels it stays green. To change that, you could try changing the loop function to this and also try changing the delay value mentioned before (double click to select and copy): void loop() { // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pix- els minus one. for(int i=0;i // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 pixels.setPixelColor(i, pixels.Color(0,0,255)); // Brigh blue color.