Huhu ich würde gerne einen Doppelschalter benutzen.
Also wenn der Schalter auf 1 Steht soll ein Programm ablaufen und wenn der Schalter auf 2 Steht ein anderes, sollte er auf Null stehen soll der Arduino kein Programm ausführen.
Leider stell ich mich gerade etwas blöd an. Ich hab schon etwas gesucht und rumexperimentiert. Aber der Schalter wird einfach nicht erkannt. Bzw nicht richtig. Die Low Position funktioniert sowie die erste Abfrage aber er springt nicht in das Nightrider Programm.
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define NUM_LIGHTS 23
#define buttonPin1 2
#define buttonPin2 3
// 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(23, 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.
uint32_t off = strip.Color(0,0,0);
uint32_t white = strip.Color(255,255,255);
uint32_t blue = strip.Color(0,0,255);
uint32_t red = strip.Color(255,0,0);
uint32_t orange = strip.Color(255,140,0);
uint32_t green = strip.Color(0,255,0);
uint32_t pink = strip.Color(255,0,255);
uint32_t violet = strip.Color(153,50,204);
int ch1;
void setup() {
pinMode(buttonPin1, INPUT);
// pinMode(buttonPin2, INPUT);
strip.begin();
strip.show();
}
void setp(int pix, uint32_t col) {
strip.setPixelColor(pix-1, col);
}
void loop(){
if (digitalRead(buttonPin1) == HIGH)
{
if (digitalRead(buttonPin1) == HIGH)
{
Licht();
}
else
{
knightRider();
}
}
else {
// Turn them off
for( int j = 0; j<NUM_LIGHTS; j++){
strip.setPixelColor(j, LOW);
strip.show();
}
}
}
void Licht() { //Blinker
setp(1,blue);
setp(2,blue);
setp(3,blue);
setp(4,blue);
setp(5,blue);
setp(6,white);
setp(7,orange);
setp(13,white);
setp(14,orange);
setp(15,blue);
setp(16,blue);
setp(17,blue);
setp(18,blue);
setp(19,blue);
setp(20,orange);
setp(21,red);
setp(22,red);
setp(23,orange);
strip.show();
delay(500);
setp(1,blue);
setp(2,blue);
setp(3,blue);
setp(4,blue);
setp(5,blue);
setp(6,white);
setp(7,off);
setp(13,white);
setp(14,off);
setp(15,blue);
setp(16,blue);
setp(17,blue);
setp(18,blue);
setp(19,blue);
setp(20,off);
setp(21,red);
setp(22,red);
setp(23,off);
strip.show();
delay(500);
}
void knightRider() {
int loops = 2;
int count = 0;
int timer = 50;
uint32_t low = strip.Color(0, 0, 0);
uint32_t high = strip.Color(255,0,0);
// Flash Lights
for(int i = 0; i < loops; i++){
for (count=7;count<11;count++) {
strip.setPixelColor(count, high);
strip.show();
delay(timer);
strip.setPixelColor(count+1,high);
strip.show();
delay(timer);
strip.setPixelColor(count, low);
strip.show();
delay(timer*2);
}
for (count=11;count>7;count--) {
strip.setPixelColor(count, high);
strip.show();
delay(timer);
strip.setPixelColor(count-1, high);
strip.show();
delay(timer);
strip.setPixelColor(count, low);
strip.show();
delay(timer*2);
}
}
// Turn them off
for( int i = 0; i<NUM_LIGHTS; i++){
strip.setPixelColor(i, LOW);
strip.show();
}
}