/********************************
since the amtel avr xplained is actuaaly nanao v3
with built in rgb strip of 3 leds connected to pin 2 as
data input to run amtel avr xplained go to arduino ide and
install from board maneger
amtel avr xplained mini and upload the code
since the mcu is not a component of wokwi i used arduino nanao
the three leds sepaeratl shown are built in board
arvind patil 23/07/24
****************************************/
#include <Adafruit_NeoPixel.h>
#include <Adafruit_NeoPixel.h>
#define PIN 2 // The pin connected to the NeoPixel strip
#define NUMPIXELS 3 // The number of LEDs in the strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
rainbowCycle(20); // Rainbow cycle with delay
}
// Function to generate rainbow colors across 0-255 positions
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
// Function for rainbow cycle
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}