/*
To use the Adafruit Ultra High Density DotStar LED PCB Bar with 128 LEDs, you will need the Adafruit DotStar library. You can install the library using the Arduino Library Manager by searching for "Adafruit DotStar" and installing the latest version.
This code will create a color chase animation with red, green, and blue colors on the DotStar LED PCB Bar with 128 LEDs.
Before uploading the code to your Arduino, make sure to wire the DotStar LED PCB Bar correctly:
Connect the 5V pin of the DotStar LED PCB Bar to the 5V pin on the Arduino.
Connect the GND pin of the DotStar LED PCB Bar to the GND pin on the Arduino.
Connect the CI (Clock Input) pin of the DotStar LED PCB Bar to the clock pin (SCK) on the Arduino. In this example, we are using pin 5.
Connect the DI (Data Input) pin of the DotStar LED PCB Bar to the data pin (MOSI) on the Arduino. In this example, we are using pin 4.
Upload the code to your Arduino, and you should see the color chase animation on the DotStar LED PCB Bar. You can customize the colors and animation speed by modifying the colorChase() function calls in the loop() function.
*/
#include <Adafruit_DotStar.h>
#include <SPI.h> // Needed for hardware SPI
#define NUMPIXELS 128 // Number of LEDs on the PCB Bar
#define DATAPIN 4 // Data pin (MOSI) connected to the DotStar strip
#define CLOCKPIN 5 // Clock pin (SCK) connected to the DotStar strip
// Initialize the DotStar strip using hardware SPI
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
void setup() {
strip.begin(); // Initialize the DotStar strip
strip.show(); // Turn off all the LEDs (they might be on from the start)
}
void loop() {
// Run a simple color chase animation
colorChase(strip.Color(255, 0, 0), 50); // Red
colorChase(strip.Color(0, 255, 0), 50); // Green
colorChase(strip.Color(0, 0, 255), 50); // Blue
}
// Function to run a color chase animation
void colorChase(uint32_t color, uint8_t wait) {
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, color); // Set the color for the current pixel
strip.show(); // Display the updated colors on the strip
strip.setPixelColor(i, 0); // Clear the color for the current pixel
delay(wait); // Pause before moving to the next pixel
}
}
Comments