//***************Arduino Code from Video*************************************
/* This Arduino sketch was made for a tutorial entitled "Building a Fun and Scalable RGB LED Display Part 1" for the ForceTronics YouTube Channel
* This sketch was leveraged from an example with the Adafruit NeoPixel library.This sketch was used to compare performance of an Arduino UNO versus
* the Altrium Sno FPGA based Arduino for controlling the ADafruit NeoMatrix. This sketch randomly changes each pixel's brightness and color in a timed
* loop.
* This code is free for others to use and modify at their own risk
*/
#include <Adafruit_NeoPixel.h> //uncomment this library when using an AVR based Arduino
//#include <XLR8NeoPixel.h> //uncomment this library when using the SNO
// Defines single pin to control NeoMatrix from Arduino
#define PIN 6
//defines number of pixels in the NeoMatrix that was used
#define NUMPIXELS 64
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use
//We can also set the comm speed and settings related to the how the NeoMatrix is configured
//For more information on how to use arguments for this function go to: https://learn.adafruit.com/adafruit-neopixel-uberguide/neomatrix-library
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //decomment this function if you are using an AVR based Arduino
//XLR8NeoPixel pixels = XLR8NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //uncomment this function if you are using the SNO FPGA Arduino
int delayval = 10; // delay for 10 msec
void setup() {
pixels.begin(); // This initializes the NeoPixel or XLR8NeoPixel library.
}
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
//This loops through all the pixels (1 to 64) and then starts back at 1
for(int i=0;i<NUMPIXELS;i++){
//This function sets the brightness of a pixel. Brightness can be 0 to 255. Using random() to generate psuedo random value between 0 and 255
pixels.setBrightness(random(0,255));
//This function sets the color scheme of an RGB LED, so values are red 0 to 255, green 0 to 255, blue 0 to 255.
//'i' is the pixel number that is being set and the other arguments are the RGB values which are set using psuedo random values between 0 and 255
pixels.setPixelColor(i, pixels.Color(random(0,255),random(0,255),random(0,255))); // Moderately bright green color.
//This function updates the pixels
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
No comments:
Post a Comment