/*#include <Adafruit_NeoPixel.h>
#define PIN 9
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit... if you must, connect GND first.
void setup() {
strip.begin();
strip.show(); // initialize all pixels to "off"
}
void loop() {
brighten();
darken();
}
// 0 to 255
void brighten() {
uint16_t i, j;
for (j = 0; j < 100; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, j, 0);
}
strip.show();
delay(10);
}
delay(1500);
}
// 255 to 0
void darken() {
uint16_t i, j;
for (j = 100; j > 0; j--) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, j, 0);
}
strip.show();
delay(10);
}
delay(1500);
}*/
/**************************************************************************************************
* Arduino Sketch for NeoPixel Ring with Rotating Effect
*
* This code controls a 12-LED NeoPixel ring to create a rotating effect. The LEDs light up in
* sequence in a clockwise direction, leaving a trailing effect as they turn off. The sketch
* utilizes the FastLED library to manage the LED strip and create the desired visual effect.
*
* Components:
* - Arduino Nano
* - Adafruit 12 NeoPixel Ring
*
* Connections:
* - NeoPixel Ring Data Pin -> Arduino Pin D11
* - Power and Ground connections as per the circuit design
*
* Libraries:
* - FastLED: Used for controlling the NeoPixel LEDs
*
* Author: [Your Name]
* Date: [Date]
***************************************************************************************************/
#include <FastLED.h>
#define NUM_LEDS 12 // Define the number of LEDs in the NeoPixel ring
#define DATA_PIN 9 // Define the data pin for the NeoPixel ring
#define DELAY_TIME 125 // Define the delay time for the rotation effect
CRGB leds[NUM_LEDS]; // Create an array to hold the LED data
void setup()
{
// Initialize the FastLED library
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
}
void loop() {
// Rotate the LEDs in a clockwise direction
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB::Red;
for (int j = 1; j <= 5; j++) // Create a trailing effect by dimming the previous LEDs
{
int index = (i - j + NUM_LEDS) % NUM_LEDS;
leds[index].fadeToBlackBy(85); // Adjust the fade amount for the trail
}
FastLED.show();
delay(DELAY_TIME); // Wait for a short period before moving to the next LED
}
}