I have a 7 X WS2812B 5050 RGB LED Ring that Im trying to activate with a grounded metal ball tilt switch. what I would like it to do is when the switch is activated Id like the led to go from dim to bright rather fast in white color. and deactivate as soon as the switch is deactivated... it's for an Iron man Hand repulsor, Im using an Arduino Nano to control with.
this is the code I was starting with from another project. Im new to coding so any help would be greatly appreciated..
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 6
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 1; // delay between each LED's
void setup() {
pixels.begin(); // This initializes the NeoPixel library.
}
void turnoff()
{
int i;
for(i=0;i<NUMPIXELS;i++)
{
pixels.setPixelColor(i, pixels.Color(0,0,0));
}
pixels.show();
}
void loop() {
int i;
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one
for(i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,255,255)); // white
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
while(1);
}