Hi,
der Level Shifter, um von 3.3V am D1 Mini auf 5V als PWM für den RGB Di.
Is so ein 4 Kanal konverter von AZ Delivery.
Die haben den aber nicht mehr - nur noch den 8 Kanal
Ah, doch, da: IOT 4 Kanal IIC I2C Premium Pegelwandler | Bi-direktionales 5V zu 3.3V
Funktioniert ganz gut und deckt sich mit der / oder vielen Dokus, die ich gefunden habe.
Die Schaltpläne, die ich kombiniert habe:
Die RGB NeoPixel steuere ich so an (12V Version - untere Bild, von WLED Projekt - Getting Started):
und die beiden WW und CW habe ich jeweils so angeschlossen (Bild auch von WLED Projekt - Getting Started):

Code - Hm... Laaaaaaaang. Ich versuche es mal:
relevante Codeausschnitte von RGB NeoPixel ansteuerung:
void moduleNeoPixel::init() {
strip = new Adafruit_NeoPixel(pixelCount, neoPixelPin, NEO_RGB + NEO_KHZ800);
}
void moduleNeoPixel::cycle() {
if(wpFZ.calcValues) {
calc();
}
publishValues();
}
void moduleNeoPixel::calc() {
unsigned long currentMillis = millis();
if(demoMode) {
if((currentMillis - patternPrevious) >= patternInterval) {
patternPrevious = currentMillis;
if(++modeCurrent > 9)
modeCurrent = 1;
}
}
if(currentMillis - pixelPrevious >= pixelInterval) {
pixelPrevious = currentMillis;
switch (modeCurrent) {
case ModeColorWipeRed:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "colorWipe Red");
ColorWipeEffect(strip->Color(255, 0, 0), 50); // Red
break;
case ModeColorWipeGreen:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "colorWipe Green");
ColorWipeEffect(strip->Color(0, 255, 0), 50); // Green
break;
case ModeColorWipeBlue:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "colorWipe Blue");
ColorWipeEffect(strip->Color(0, 0, 255), 50); // Blue
break;
case ModeTheaterChaseWhite:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "theaterChase White");
TheaterChaseEffect(strip->Color(127, 127, 127), 50); // White
break;
case ModeRainbow:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "rainbow");
RainbowEffect(10); // Flowing rainbow cycle along the whole strip
break;
case ModeRunnerRed:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Runner Red");
RunnerEffect(strip->Color(127, 0, 0), 50); // Runner Red
break;
case ModeRunnerGreen:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Runner Green");
RunnerEffect(strip->Color(0, 127, 0), 50); // Runner Green
break;
case ModeRunnerBlue:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Runner Blue");
RunnerEffect(strip->Color(0, 0, 127), 50); // Runner Blue
break;
case ModeRandom:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Random");
RandomEffect(500); // Random
break;
case ModeComplex:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Complex");
break;
default:
if(modeCurrentLast != modeCurrent)
wpMqtt.mqttClient.publish(mqttTopicModeName.c_str(), "Mode Static");
SimpleEffect(valueR, valueG, valueB);
break;
}
modeCurrentLast = modeCurrent;
}
}
// example Effects
void moduleNeoPixel::RandomEffect(int wait) {
int pixel;
byte r, g, b;
pixelInterval = wait;
strip->clear();
r = random(0, 255);
g = random(0, 255);
b = random(0, 255);
strip->fill(strip->Color(r, g, b));
for(uint p = 0; p < 20; p++) {
pixel = random(0, pixelCount);
r = random(0, 255);
g = random(0, 255);
b = random(0, 255);
strip->setPixelColor(pixel, strip->Color(r, g, b));
}
strip->show();
}
void moduleNeoPixel::SimpleEffect(byte r, byte g, byte b) {
setValueR(r);
setValueG(g);
setValueB(b);
demoMode = false;
modeCurrent = ModeStatic;
strip->fill(strip->Color(r, g, b));
strip->show();
}
relevante Codeausschnitte von PWM ansteuerung (CW && WW) jeweils eine Instanz:
void moduleAnalogOut::init() {
// section for define
analogOutPin = D6;
pinMode(analogOutPin, OUTPUT_OPEN_DRAIN);
}
void moduleAnalogOut::calc() {
if(handValue != handValueSet) {
handValue = handValueSet;
}
if(handError != handSet) {
handError = handSet;
}
if(handError) {
output = handValue;
} else {
output = autoValue;
}
uint16 hardwareout = wpFZ.Map(output, 0, 100, 0, 255);
analogWrite(analogOutPin, hardwareout);
}
und vielleicht noch daraus:
long wpFreakaZone::Map(long in, long inMin, long inMax, long outMin, long outMax) {
if(inMax - inMin == 0) {
DebugWS(strERRROR, "Map", "risky math operation: 'inMax - inMin == 0'");
return 0;
}
long returns = map(in, inMin, inMax, outMin, outMax);
if(returns < outMin) returns = outMin;
if(returns > outMax) returns = outMax;
return returns;
}
// seems like global, static
wpFreakaZone wpFZ;