Ich habe mir jez noch mal das von Tweaking4all angeschaut. da ja dort was mit setALL steht....
habe dann meinen etwas umgeschrieben und eingefügt...
hier der Sketch.. Es funktioniert.
#include <Adafruit_NeoPixel.h>
#define N_LEDS 15
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
const byte tasterPin = 7;
int lichtmodus = 0;
bool aktTasterStatus, altTasterStatus, ohneVerzoegerung;
const byte potPin = A0;
uint32_t intervall;
int pos = 0, dir = 1; // Position, direction of "eye"
#define INTER_FLASH_DELAY 30
#define INTER_FLASH_COUNT 10
#define INTER_FADE_DELAY 10
void setup() {
strip.begin();
pinMode (tasterPin, INPUT_PULLUP);
Serial.begin(9600);
Serial.println(F("Anfang"));
intervall = analogRead(potPin);
Serial.print(F("Intervall: ")); //gibt Text/Variablen auf der Seriellen aus
Serial.println(intervall);
}
void setFarbe (const byte n, byte r, byte g, byte b)
{
for (byte i = 0; i < n; i++)
{
strip.setPixelColor(i, strip.Color(r, g, b));
}
}
void verzoegerung(uint32_t zeit)
{
if (ohneVerzoegerung) return;
uint32_t entprellMillis = 0, vorhin = millis();
while (1)
{
uint32_t jetzt = millis();
altTasterStatus = aktTasterStatus;
aktTasterStatus = digitalRead(tasterPin);
if ((aktTasterStatus != altTasterStatus) && (jetzt - entprellMillis >= 30))
{
entprellMillis = jetzt;
if (!aktTasterStatus)
{
lichtmodus++;
ohneVerzoegerung = true; // bei einem Wechsel des Lichtmodus möglichst schnell weiter
Serial.print(F("Neuer Lichtmodus: "));
Serial.println(lichtmodus);
break;
}
}
if (jetzt - vorhin >= zeit)
{
break;
}
}
}
void loop()
{
ohneVerzoegerung = false;
verzoegerung(0); // damit die Tasten immer abgefragt werden
switch (lichtmodus)
{
case 0:
intervall = analogRead(potPin);
Serial.print(F("Intervall: ")); //gibt Text/Variablen auf der Seriellen aus
Serial.println(intervall);
// Rather than being sneaky and erasing just the tail pixel,
// it's easier to erase it all and draw a new one next time.
for (uint16_t j = 0; j < N_LEDS; j++) strip.setPixelColor(j, 0);
// Draw 5 pixels centered on pos. setPixelColor() will clip any
// pixels off the ends of the strip, we don't need to watch for that.
strip.setPixelColor(pos - 1, 0x696969);
strip.setPixelColor(pos , 0xFFFFFF); // Center pixel is brightest
strip.setPixelColor(pos + 1, 0x696969);
if (!ohneVerzoegerung) strip.show();
verzoegerung(intervall);
// Bounce off ends of strip
pos += dir;
if (pos < 0) {
pos = 1;
dir = -dir;
} else if (pos >= N_LEDS) {
pos = N_LEDS - 2;
dir = -dir;
}
break;
case 1:
for (uint16_t n = 0; n < N_LEDS; n++)
{
strip.setPixelColor(n, 138, 43, 226);
}
if (!ohneVerzoegerung) strip.show();
break;
case 2:
for (byte n = 0; n < N_LEDS; n++)
{
setFarbe(N_LEDS, 0, 0, 255); // alle blau
if (!ohneVerzoegerung) strip.show();
verzoegerung(INTER_FLASH_DELAY);
setFarbe(N_LEDS, 0, 0, 0); // alle aus
if (!ohneVerzoegerung) strip.show();
verzoegerung(INTER_FLASH_DELAY);
}
break;
case 3:
FadeInOut(0xff, 0xff, 0xff);
break;
default:
lichtmodus = 0;
Serial.print(F("Neuer Lichtmodus: "));
Serial.println(lichtmodus);
}
}
void FadeInOut(byte red, byte green, byte blue) {
float r, g, b;
for (int k = 0; k < 256; k = k + 1) {
r = (k / 256.0) * red;
g = (k / 256.0) * green;
b = (k / 256.0) * blue;
setAll(r,g,b);
if (!ohneVerzoegerung) strip.show();
verzoegerung(INTER_FADE_DELAY);
}
for (int k = 255; k >= 0; k = k - 2) {
r = (k / 256.0) * red;
g = (k / 256.0) * green;
b = (k / 256.0) * blue;
setAll(r,g,b);
if (!ohneVerzoegerung) strip.show();
verzoegerung(INTER_FADE_DELAY);
}
}
void setAll(byte red, byte green, byte blue)
{
for(int i = 0; i < N_LEDS; i++ )
{
setPixel(i, red, green, blue);
}
strip.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
Alle LEDS werden nun gleichmäßig hoch und runter gedämmt..
es ist bestimmt noch nicht wirklich schön und im sonne des Erfinders.
Ich werde mich nun damit beschäftigen wieso es auf einmal geht und schauen ob ich es verstehe und anpassen kann...
Dennoch danke ich euch viel Mals für die starken nerven für mich und die ganze Hilfe...
ach und @Tommy um dein Beitrag nicht umkommentiert zu lassen.
Hier die Fehlermeldung
Arduino: 1.8.7 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"
/Users/User/Documents/Arduino/lauflicht_mit_fade_falsch/lauflicht_mit_fade_falsch.ino: In function 'void FadeInOut(byte, byte, byte)':
lauflicht_mit_fade_falsch:136:32: error: no matching function for call to 'Adafruit_NeoPixel::setPixelColor(float&, float&, float&)'
strip.setPixelColor(r, g, b);
^
In file included from /Users/User/Documents/Arduino/lauflicht_mit_fade_falsch/lauflicht_mit_fade_falsch.ino:1:0:
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:206:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint8_t, uint8_t, uint8_t)
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:206:21: note: candidate expects 4 arguments, 3 provided
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:207:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint8_t, uint8_t, uint8_t, uint8_t)
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b,
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:207:21: note: candidate expects 5 arguments, 3 provided
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:209:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint32_t)
void setPixelColor(uint16_t n, uint32_t c);
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:209:21: note: candidate expects 2 arguments, 3 provided
lauflicht_mit_fade_falsch:145:32: error: no matching function for call to 'Adafruit_NeoPixel::setPixelColor(float&, float&, float&)'
strip.setPixelColor(r, g, b);
^
In file included from /Users/User/Documents/Arduino/lauflicht_mit_fade_falsch/lauflicht_mit_fade_falsch.ino:1:0:
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:206:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint8_t, uint8_t, uint8_t)
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:206:21: note: candidate expects 4 arguments, 3 provided
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:207:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint8_t, uint8_t, uint8_t, uint8_t)
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b,
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:207:21: note: candidate expects 5 arguments, 3 provided
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:209:21: note: candidate: void Adafruit_NeoPixel::setPixelColor(uint16_t, uint32_t)
void setPixelColor(uint16_t n, uint32_t c);
^
/Users/User/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:209:21: note: candidate expects 2 arguments, 3 provided
exit status 1
no matching function for call to 'Adafruit_NeoPixel::setPixelColor(float&, float&, float&)'