Hello,
I just build a light for under my drone which can attached under it to do some lightpainting.
It was a very simple build.
9V battery - ubec 5v-7A - arduino nano - 8 ws2812 Leds - dipswitch 4x
My idea was to get white on dipswitch 1 and other colors on the other dipswitch.
just tried to get 3 colors. I do have power on my nano and led, but there is no light.
The dipswitch is input-pullup
Do I have the code not right?
thank you.
Bert
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// How many NeoPixels are attached to the Arduino?
#define PIXEL_PIN 6
#define PIXEL_COUNT 8 // Number of NeoPixels
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
int DIP2 = 2;
int DIP3 = 3;
int DIP4 = 4;
int DIP5 = 5;
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
//pinMode(6, OUTPUT);
strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
DIP2 = digitalRead(2);
DIP3 = digitalRead(3);
DIP4 = digitalRead(4);
DIP5 = digitalRead(5);
if (DIP2 == LOW ){
strip.setPixelColor(60, 255, 255, 255);
strip.show(); // Initialize all pixels to 'off'
}
else if (DIP3 == LOW ){
strip.setPixelColor(60, 0, 255, 0);
strip.show(); // Initialize all pixels to 'off'
}
else if (DIP4 == LOW ){
strip.setPixelColor(60, 255, 0, 0);
strip.show(); // Initialize all pixels to 'off'
}
else if (DIP5 == LOW ){
strip.setPixelColor(60, 0, 0, 255);
strip.show(); // Initialize all pixels to 'off'
}
else if (DIP2 == LOW, DIP3 == LOW, DIP4 == LOW, DIP5 == LOW ){
strip.setPixelColor(0, 0, 0, 0); // Zwart, is uit
strip.show(); // Initialize all pixels to 'off'
}
}