Hello community,
i have been using a Teensy 3.5 to control my WS2812B Neopixels and was happy about WS2812Serial Library that made it possible to use an IR Remote at the same time.
Now i ordered a teensy 4.0 and wanted to use it within the same setup as my teensy 3.5, but it doesn't work ..
One problem seems to be, that the WS2812Serial library wasn't updated for teensy 4.0 yet, am i right? I just get a compilation Error when i try to run it.
This is the Code:
This is the error:
Then i tried a project that makes just use of the FastLED library for Teensy but it, after compiling successfully, didn't work either. Then LED stripe gets just plain white.
This is the code that compiled successfully:
I am using Pin 8 for the signal and the GND at the top left corner to connect to the LED strips ground.
Thanks in advance for every kind of advice!![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Enndee
i have been using a Teensy 3.5 to control my WS2812B Neopixels and was happy about WS2812Serial Library that made it possible to use an IR Remote at the same time.
Now i ordered a teensy 4.0 and wanted to use it within the same setup as my teensy 3.5, but it doesn't work ..
One problem seems to be, that the WS2812Serial library wasn't updated for teensy 4.0 yet, am i right? I just get a compilation Error when i try to run it.
This is the Code:
Code:
#include <WS2812Serial.h>
#define USE_WS2812SERIAL
#include <FastLED.h>
#include <IRremote.h>
#define NUM_LEDS 432
#define SEGMENTLAENGE 25
#define SEGMENTE 17
//#define SEGMENTLAENGE 432
//#define SEGMENTE 1
#define IRRECEIVE_PIN 2
// Usable pins:
// Teensy LC: 1, 4, 5, 24
// Teensy 3.2: 1, 5, 8, 10, 31 (overclock to 120 MHz for pin 8)
// Teensy 3.5: 1, 5, 8, 10, 26, 32, 33, 48
// Teensy 3.6: 1, 5, 8, 10, 26, 32, 33
#define NEOPIXEL_PIN 8
int static Programmnummer = 6;
int static Anzahl_der_Programme = 2;
int static Stopp = -1; // -1 = Stopp, 1 = Run
int static Pause = -1; // -1 = Pause, 1 = Run
int static Abbruch = 0;
int static Helligkeitsfaktor=2;
int static IR_gelesen = 0;
int static Geschwindigkeitsquotient = 5;
void (*Effektprogramme[])() = {&Matrix_fluessig, &DMT, &Blitzen, &Wanderpixel, &Regenbogen, &Strobo, &Boom};
IRrecv IrReceive(IRRECEIVE_PIN);
decode_results IR_Result;
CRGBArray<NUM_LEDS> leds;
CRGB* LEDs[SEGMENTE];
//typedef void (*f)(void);
//Alternative Initialisierung des Function Arrays
//f Effektprogramme[] = {&Matrix_fluessig, &DMT};
void setup()
{
int i;
Serial.begin(9600);
IrReceive.enableIRIn(); // Start the receiver
//FastLED.addLeds<NEOPIXEL,NEOPIXEL_PIN>(leds, NUM_LEDS);
//LEDS.addLeds<WS2812SERIAL,NEOPIXEL_PIN,RGB>(leds,NUM_LEDS);
LEDS.addLeds<WS2812SERIAL,NEOPIXEL_PIN,BRG>(leds,NUM_LEDS);
for (i = 0; i < SEGMENTE; i++)
{
LEDs[i] = &leds[i*SEGMENTLAENGE];
}
}
void loop()
{
//Serial.println("Mainloop");
CheckIR();
if (Abbruch == 1 && Stopp == 1) {Abschalten(); Pause = 1;}
Abbruch = 0;
//Serial.print("Programmnummer = "); Serial.println(Programmnummer);
if (Stopp == -1) {Effektprogramme[Programmnummer]();}
delay(50);
}
void Matrix_fluessig()
{
int i[SEGMENTE] = {0};
//int Leuchten[SEGMENTE];
int Schweiflaenge[SEGMENTE];
int Helligkeit[SEGMENTE] = {0};
int Shiftdirection[SEGMENTE] = {0};
Serial.println("Starte Matrix fluessig");
Geschwindigkeitsquotient = 7;
// Shiftdirection[1]=1;
// Shiftdirection[3]=1;
// Shiftdirection[5]=1;
// Shiftdirection[7]=1;
// Shiftdirection[9]=1;
// Shiftdirection[11]=1;
// Shiftdirection[13]=1;
// Shiftdirection[15]=1;
while (true) {
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche Matrix-Loop ab");
break;
}
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
if ((Helligkeit[Segmentnummer] == 0) && (random(1,10) > 8)) {Helligkeit[Segmentnummer] = 255; i[Segmentnummer] = 0;}
}
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
if (Helligkeit[Segmentnummer] == 255)
{
Schweiflaenge[Segmentnummer] = random(10,20);
}
if (Helligkeit[Segmentnummer] > 0)
{
Helligkeit[Segmentnummer] = 255*(Schweiflaenge[Segmentnummer]-i[Segmentnummer])/Schweiflaenge[Segmentnummer];
i[Segmentnummer]++;
}
LEDshiftByRef(LEDs[Segmentnummer], Shiftdirection[Segmentnummer]);
//if (Shiftdirection[Segmentnummer] == 0) LEDs[Segmentnummer][0] = CHSV(Segmentnummer*255/SEGMENTE,255,Helligkeit[Segmentnummer]); //Regenbogenvariante
//if (Shiftdirection[Segmentnummer] == 1) LEDs[Segmentnummer][SEGMENTE-1] = CHSV(Segmentnummer*255/SEGMENTE,255,Helligkeit[Segmentnummer]); //Regenbogenvariante
if (Shiftdirection[Segmentnummer] == 0) LEDs[Segmentnummer][0] = CHSV(82,255,Helligkeit[Segmentnummer]);
if (Shiftdirection[Segmentnummer] == 1) LEDs[Segmentnummer][SEGMENTE-1] = CHSV(82,255,Helligkeit[Segmentnummer]);
}
while(Pause == 1){delay(100); CheckIR();}
CheckIR();
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(5000/pow(2,Geschwindigkeitsquotient));
}
}
void DMT()
{
int Segmentnummer;
Geschwindigkeitsquotient = 7;
CHSV Farben[3];
// Shiftdirection[1]=1;
// Shiftdirection[3]=1;
// Shiftdirection[5]=1;
// Shiftdirection[7]=1;
// Shiftdirection[9]=1;
// Shiftdirection[11]=1;
// Shiftdirection[13]=1;
// Shiftdirection[15]=1;
Farben[0] = CHSV(1,255,255);
Farben[1] = CHSV(1,0,255);
Farben[2] = CHSV(82,255,255);
Serial.println("DMT-Programm gestartet");
while (true)
{
// if (Abbruch == 1)
// {
// Serial.println("Abbruchanforderung registriert, Breche DMT-Loop ab");
// break;
// }
for (int g = 0; g < sizeof(Farben)/3; g++)
{
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche FarbLoop ab");
return;
}
for (int j = 0; j < SEGMENTLAENGE/2; j++)
{
for (Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
CheckIR();
if (SEGMENTLAENGE % 2 == 1)
{
LEDs[Segmentnummer][(SEGMENTLAENGE+1)/2] = Farben[g];
LEDs[Segmentnummer][(SEGMENTLAENGE+1)/2-1-j] = Farben[g];
LEDs[Segmentnummer][(SEGMENTLAENGE+1)/2+1+j] = Farben[g];
}
else
{
LEDs[Segmentnummer][SEGMENTLAENGE/2-1-j] = Farben[g];
LEDs[Segmentnummer][SEGMENTLAENGE/2+j] = Farben[g];
}
}
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(5000/pow(2,Geschwindigkeitsquotient));
}
}
}
}
void Wanderpixel()
{
Geschwindigkeitsquotient = 9;
Serial.println("Wanderpixel gestartet");
Abschalten();
while (true)
{
for (int i = 0; i <= NUM_LEDS; i++)
{
CheckIR();
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche Wanderpixel ab");
return;
}
leds[i] = CHSV(1,0,255);
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(5000/pow(2,Geschwindigkeitsquotient));
leds[i] = CHSV(1,0,0);
}
}
}
void Blitzen()
{
Geschwindigkeitsquotient = 7;
Serial.println("Blitzen gestartet");
while (true)
{
if (Abbruch == 1) {return;}
//
// for (i = 0; i <= NUM_LEDS; i++)
// {
// if (random(1,10) > 5) Helligkeit = 0;
// if (random(1,10) <= 5) Helligkeit = pow(4,random(0,4));
// leds[i] = CHSV(1,0,Helligkeit);
// }
for (int i = 0; i <= NUM_LEDS; i++)
{
leds[i] = CHSV(1,0,pow(4,random(-20,4)));
}
CheckIR();
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(5000/pow(2,Geschwindigkeitsquotient));
}
}
void Regenbogen()
{
Serial.println("Regenbogen gestartet");
Geschwindigkeitsquotient = 7;
while (true)
{
if (Abbruch == 1) {return;}
for (int colorshift = 0; colorshift <= 255; colorshift = colorshift+5)
{
for (int i = 0; i <= SEGMENTLAENGE; i++)
{
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
LEDs[Segmentnummer][i] = CHSV(Diff255(map(i, 0, SEGMENTLAENGE, 0, 255)+colorshift),255,255);
//LEDs[Segmentnummer][i] = CHSV(Diff255(map(i, 0, SEGMENTLAENGE, 0, 255)),255,255);
}
}
CheckIR();
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(5000/pow(2,Geschwindigkeitsquotient));
}
}
}
void Strobo()
{
Serial.println("Strobo gestartet");
Geschwindigkeitsquotient = 6;
while (true)
{
if (Abbruch == 1) {return;}
for (int i = 0; i <= NUM_LEDS; i++)
{
leds[i] = CHSV(1,0,255);
}
FastLED.show();
for (int i = 0; i <= NUM_LEDS; i++)
{
leds[i] = CHSV(1,0,0);
}
CheckIR();
while(Pause == 1){delay(100); CheckIR();}
FastLED.show();
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
delay(5000/pow(2,Geschwindigkeitsquotient));
}
}
void Boom()
{
Geschwindigkeitsquotient = 6;
Serial.println("Boom gestartet");
Abschalten();
while (true)
{
for (int i = 0; i <= SEGMENTLAENGE/2; i++)
{
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
CheckIR();
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche Wanderpixel ab");
return;
}
if (i>0) {LEDs[Segmentnummer][i-1] = CHSV(1,0,0); LEDs[Segmentnummer][SEGMENTLAENGE-i+1] = CHSV(1,0,0);}
LEDs[Segmentnummer][i] = CHSV(1,0,120);
LEDs[Segmentnummer][SEGMENTLAENGE-i] = CHSV(1,0,120);
}
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(15000/pow(2,Geschwindigkeitsquotient));
}
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
LEDs[Segmentnummer][SEGMENTLAENGE/2] = CHSV(1,0,255);
LEDs[Segmentnummer][SEGMENTLAENGE-SEGMENTLAENGE/2] = CHSV(1,0,255);
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(255);
FastLED.show();
delay(30);
}
for (int i = SEGMENTLAENGE/2+1; i >= 0; i--)
{
CheckIR();
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche Wanderpixel ab");
return;
}
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
LEDs[Segmentnummer][i] = CHSV(i*3,255,255);
LEDs[Segmentnummer][SEGMENTLAENGE-i] = CHSV(i*3,255,255);
}
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(2500/pow(2,Geschwindigkeitsquotient));
}
for (int i = SEGMENTLAENGE/2+1; i >= 0; i--)
{
CheckIR();
if (Abbruch == 1)
{
Serial.println("Abbruchanforderung registriert, Breche Wanderpixel ab");
return;
}
for (int Segmentnummer = 0; Segmentnummer < SEGMENTE; Segmentnummer++)
{
LEDs[Segmentnummer][i] = CHSV(i,255,0);
LEDs[Segmentnummer][SEGMENTLAENGE-i] = CHSV(i,255,0);
}
while(Pause == 1){delay(100); CheckIR();}
FastLED.setBrightness(pow(4,Helligkeitsfaktor)-1);
FastLED.show();
delay(2500/pow(2,Geschwindigkeitsquotient));
}
delay(1000);
}
}
void CheckIR()
{
if (IrReceive.decode(&IR_Result))
{
Serial.println(IR_Result.value);
switch(IR_Result.value)
{
case 16761405: if (Programmnummer < sizeof(Effektprogramme)/4-1) {Programmnummer++; Serial.print("Programmnummer = "); Serial.println(Programmnummer); Abbruch = 1;} break;
case 16720605: if (Programmnummer > 0) {Programmnummer--; Serial.print("Programmnummer = "); Serial.println(Programmnummer); Abbruch = 1;} break;
case 16753245: Stopp = Stopp * -1; Pause = -1; Serial.print("Stopp = "); Serial.println(Stopp); Abbruch = 1; break;
case 16736925: if (Helligkeitsfaktor < 4) {Helligkeitsfaktor++; Serial.print("Helligkeitsfaktor = "); Serial.println(Helligkeitsfaktor);} break;
case 16754775: if (Helligkeitsfaktor > -1) {Helligkeitsfaktor--; Serial.print("Helligkeitsfaktor = "); Serial.println(Helligkeitsfaktor);} break;
case 16769055: if (Geschwindigkeitsquotient > 0) {Geschwindigkeitsquotient--; Serial.print("Geschwindigkeitsquotient = "); Serial.println(Geschwindigkeitsquotient);} break;
case 16748655: if (Geschwindigkeitsquotient < 9) {Geschwindigkeitsquotient++; Serial.print("Geschwindigkeitsquotient = "); Serial.println(Geschwindigkeitsquotient);} break;
case 16712445: Pause = Pause * -1; Stopp = -1; Serial.print("Pause = "); Serial.println(Pause); break;
}
IrReceive.resume();
}
}
//void LoopcallwithTimeout(int (*Functionpointer)(), int Timeoutms)
//{
// long Timeoutstartzeit;
//
// Timeoutstartzeit = millis();
// while (((millis() - Timeoutstartzeit) <= Timeoutms))
// {
// Functionpointer();
// if (IR_gelesen == 1) {IR_gelesen = 0; return;}
// delay(50);
// }
// IrReceive.resume();
//}
//
//void Debugln(String Nachricht)
//{
// Serial.println(Nachricht);
//}
//
//void Debugfloat(float Zahl)
//{
// Serial.println(Zahl);
//}
//
//void Debugmsg(String Nachricht, float Variable)
//{
// Serial.print(Nachricht);
// Serial.println(Variable);
//}
//
//void Pause()
//{
// Serial.println("Pause wurde gedrückt.");
// Stopp = Stopp * -1;
//}
void Abschalten()
{
Serial.println("Abschalten aufgerufen");
int i;
Abbruch = 0;
for (i = 0; i <= NUM_LEDS; i++)
{
leds[i] = CHSV(1,0,0);
}
FastLED.show();
}
void LEDshiftByRef(CRGB* LEDs, int Richtung)
{
int i;
if (Richtung == 0)
{
for (i = SEGMENTLAENGE-1; i >= 1; i--)
{
LEDs[i]=LEDs[i-1];
}
}
if (Richtung == 1)
{
for (i = 0; i <= SEGMENTLAENGE-1; i++)
{
LEDs[i]=LEDs[i+1];
}
}
}
int Diff255(int Summe)
{
if (Summe >= 255)
{
return Summe - 255;
}
else
{
return Summe;
}
}
This is the error:
Code:
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=147 -DARDUINO=10809 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Users\\ifeel\\AppData\\Local\\Temp\\arduino_build_393761/pch" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy4" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\WS2812Serial" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\FastLED" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SPI" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\IRremote" "C:\\Users\\ifeel\\AppData\\Local\\Temp\\arduino_build_393761\\sketch\\Masterprogramm_SerialLED.ino.cpp" -o "C:\\Users\\ifeel\\AppData\\Local\\Temp\\arduino_build_393761\\sketch\\Masterprogramm_SerialLED.ino.cpp.o"
In file included from Z:\Daten\OneDrive\Unverschlüsselt\Projekte\Infinity Cube\Arduino\Sources\LED_Stripe_Kontrolle\Masterprogramm_SerialLED\Masterprogramm_SerialLED.ino:3:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.000
# pragma message "FastLED version 3.003.000"
^
In file included from Z:\Daten\OneDrive\Unverschlüsselt\Projekte\Infinity Cube\Arduino\Sources\LED_Stripe_Kontrolle\Masterprogramm_SerialLED\Masterprogramm_SerialLED.ino:3:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h: In static member function 'static CLEDController& CFastLED::addLeds(CRGB*, int, int)':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:393:10: error: 'CWS2812SerialController' does not name a type
static CWS2812SerialController<DATA_PIN,RGB_ORDER> controller;
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:394:19: error: 'controller' was not declared in this scope
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset);
^
Masterprogramm_SerialLED: In function 'void DMT()':
Masterprogramm_SerialLED:179: warning: comparison between signed and unsigned integer expressions
Masterprogramm_SerialLED: In function 'void CheckIR()':
Masterprogramm_SerialLED:456: warning: comparison between signed and unsigned integer expressions
Z:\Daten\OneDrive\Unverschlüsselt\Projekte\Infinity Cube\Arduino\Sources\LED_Stripe_Kontrolle\Masterprogramm_SerialLED\Masterprogramm_SerialLED.ino: At global scope:
Masterprogramm_SerialLED:22: warning: 'Anzahl_der_Programme' defined but not used
Masterprogramm_SerialLED:27: warning: 'IR_gelesen' defined but not used
Bibliothek WS2812Serial im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\WS2812Serial (legacy) wird verwendet
Bibliothek FastLED in Version 3.3.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED wird verwendet
Bibliothek SPI in Version 1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI wird verwendet
Bibliothek IRremote in Version 2.2.3 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\IRremote wird verwendet
Fehler beim Kompilieren für das Board Teensy 4.0.
Then i tried a project that makes just use of the FastLED library for Teensy but it, after compiling successfully, didn't work either. Then LED stripe gets just plain white.
This is the code that compiled successfully:
Code:
#include <FastLED.h>
#define NUM_LEDS 144
#define LED_PIN 8
CRGBArray<NUM_LEDS> leds;
void setup()
{
FastLED.addLeds<NEOPIXEL,LED_PIN>(leds, NUM_LEDS);
}
void loop()
{
int i;
for (i = 0; i <= NUM_LEDS; i++)
{
leds[i] = CHSV((map(i, 0, NUM_LEDS, 0, 255)),255,40);
}
FastLED.show();
}
int Diff255(int Summe)
{
if (Summe >= 255)
{
return Summe - 255;
}
else
{
return Summe;
}
}
I am using Pin 8 for the signal and the GND at the top left corner to connect to the LED strips ground.
Thanks in advance for every kind of advice!
Enndee