/********************************************************************************
To create a beautiful rainbow art display using the FastLED library with a 16x16 LED
matrix connected to an Arduino via Pin 3, you can follow the steps below. Make sure you
have the FastLED library installed in your Arduino IDE before proceeding.
Wiring:
Connect your 16x16 LED matrix to the Arduino board. Typically,
LED matrices come with their own driver chips that simplify the wiring process.
Install the FastLED library:
Open the Arduino IDE, go to "Sketch" > "Include Library" >
"Manage Libraries...". Search for "FastLED" and click "Install" to add the library to your IDE.
Upload the code:
Connect your Arduino board to your computer, select the correct board and port under
"Tools" in the Arduino IDE, and then click the "Upload" button to upload the code
to the Arduino.
Once uploaded, the Arduino will start displaying the beautiful rainbow art
on the 16x16 LED matrix connected to Pin 3. The code creates a moving rainbow pattern that should look visually pleasing. You can adjust the step value and delay to change the speed and smoothness of the animation according to your preference. Play around with different values to
achieve different visual effects.
by arvind patil 2/8/23
*************************************************************************************/
#include <FastLED.h>
#define LED_MATRIX_PIN 3
#define LED_MATRIX_WIDTH 16
#define LED_MATRIX_HEIGHT 16
CRGB leds[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT];
void setup() {
// Initialize FastLED with the LED matrix configuration
FastLED.addLeds<NEOPIXEL, LED_MATRIX_PIN>(leds, LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT);
FastLED.setBrightness(200); // Adjust this value to set the brightness of the LEDs
}
void loop() {
// Call your beautiful rainbow art function here
displayRainbowArt();
}
// Function to display the beautiful rainbow art on the LED matrix
void displayRainbowArt() {
// Define some constants for the rainbow effect
static uint8_t hue = 0; // Start hue at 0 (red)
static uint8_t step = 8; // Change this value to control the speed of the rainbow
// Fill the matrix with the rainbow colors
for (int y = 0; y < LED_MATRIX_HEIGHT; y++) {
for (int x = 0; x < LED_MATRIX_WIDTH; x++) {
// Calculate the index in the 1D array based on the 2D position
int ledIndex = y * LED_MATRIX_WIDTH + x;
// Set the LED color using the current hue value
leds[ledIndex] = CHSV(hue + x * 4 + y * 4, 255, 255); // Adjust the "4" values to control the color pattern
}
}
// Show the LEDs
FastLED.show();
// Increment the hue for the next frame
hue += step;
// Wrap the hue value around
if (hue >= 255) {
hue = 0;
}
// Add a small delay to control the speed of the animation
delay(50); // Adjust this value to change the animation speed
}
FPS: 0
Power: 0.00W
Power: 0.00W