SoulReaver
Member
Hello Guys
this is my first post in a forum. I hope you are not angry with me if I do something wrong.
So it's about my Teensy 3.2. I have made two weeks ago a cloud ceiling with a WS2812B LED stripe. The stripe has a total of 530 LEDS. I can switch the colors via an infrared remote control without any problems. The problem now is that the last 50 LEDS flicker and shine in other colors. This worked in the beginning, but after two weeks the problem started. There is a radar sensor on the Teensy that detects movement in the room and turns on the leds. On the PC is a USB for the analog input so that the teensy recognizes that the PC is on. I have chosen the analog input because I use a line with several wires. The individual wires interfere with each other. One output is for a logic level transistor for the leds behind the monitors. The led strips are powered by a 40 amp power supply and it feeds into the strip every two meters.
The teensy also gets very hot, so I have mounted a cooler. Is this normal that the CPU gets so hot? CPU speed is 96 Mhz. I have also tried with slower speeds, but without success. I have also made a circuit diagram. I think the problem is with my code. The code is not so nice but it worked.
I hope you can help me.
Thanks.
YouTubeVideo:
https://www.youtube.com/shorts/dJuSyaXSqLk?&ab_channel=FightIncc
WireDiagram:
this is my first post in a forum. I hope you are not angry with me if I do something wrong.
So it's about my Teensy 3.2. I have made two weeks ago a cloud ceiling with a WS2812B LED stripe. The stripe has a total of 530 LEDS. I can switch the colors via an infrared remote control without any problems. The problem now is that the last 50 LEDS flicker and shine in other colors. This worked in the beginning, but after two weeks the problem started. There is a radar sensor on the Teensy that detects movement in the room and turns on the leds. On the PC is a USB for the analog input so that the teensy recognizes that the PC is on. I have chosen the analog input because I use a line with several wires. The individual wires interfere with each other. One output is for a logic level transistor for the leds behind the monitors. The led strips are powered by a 40 amp power supply and it feeds into the strip every two meters.
The teensy also gets very hot, so I have mounted a cooler. Is this normal that the CPU gets so hot? CPU speed is 96 Mhz. I have also tried with slower speeds, but without success. I have also made a circuit diagram. I think the problem is with my code. The code is not so nice but it worked.
I hope you can help me.
Thanks.
YouTubeVideo:
https://www.youtube.com/shorts/dJuSyaXSqLk?&ab_channel=FightIncc
WireDiagram:
Code:
#include <FastLED.h>
#include <IRremote.h>
int gHue = 0;
int Helligkeit = 240;
int Berechtigung = 0;
int Berechtigung1 = 0;
bool gReverseDirection = false;
int Zustand;
int IST_PC_AN;
int TIME = 0.0;
int Freigabe = 0;
#define LEDPIN 13
#define RECV_PIN 2
#define PCLED 3
#define SensorPin 6
#define LED_TYPE WS2812B
#define NUM_LEDS 530
#define FRAMES_PER_SECOND 80
#define COOLING 55
#define SPARKING 120
CRGB leds[NUM_LEDS];
CRGB endclr;
CRGB midclr;
// Infrarot
IRrecv irrecv(RECV_PIN);
decode_results results;
//<————————————————————————————SETUP————————————————————————————>
void setup()
{
//begin serial communication
Serial.begin(9600);
//MikrowellenSensor
pinMode(SensorPin, INPUT);
pinMode(PCLED, OUTPUT);
//sanity delay
delay(3000);
//start the receiver
irrecv.enableIRIn();
//set up LED strip information
FastLED.addLeds<LED_TYPE, LEDPIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(Helligkeit);
}
//<—————————————————————————LOOP———————————————————————————————>
void loop()
{
//---------------------------------------------------------------------------Serielle Augabe
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
irrecv.resume(); // Receive the next value
}
EVERY_N_MILLISECONDS( 20 ) {
gHue++;
}
//Sensorwert wird ausgelesen und in Zustand geschrieben. 1 oder 0
Zustand = digitalRead(SensorPin);
IST_PC_AN = analogRead(A0);
//Wenn der Sensor was erkannt hat, wird die Zeit gesetzt
if ((Zustand == 1) || (IST_PC_AN == 1023))
{
TIME = 2500; // <--- Hier kann man die Zeit ändern
}
//Serial.println(TIME);
//Wenn der Sensor was erkannt hat LED an
if ((TIME >= 1))
{
digitalWrite(PCLED, HIGH); //LED vom PC anmachen
//-------------------------------------------------------------------------------Aus
if (results.value == 16712445) {
FastLED.clear();
FastLED.show();
}
//---------------------------------------------------------------------------------Tasten
//power button = plain white
if (results.value == 16720605) {
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.show();
}
//---------------------------------------------------------------------------Vol+ = Helligkeit +
if (results.value == 16726725 && Helligkeit < 240 && Berechtigung == 0) {
Helligkeit = Helligkeit + 20;
FastLED.setBrightness(Helligkeit);
Serial.println(Helligkeit);
Berechtigung = 1;
}
//----------------------------------------------------------------------------vol- = Helligkeit -
if (results.value == 16759365 && Helligkeit > 20 && Berechtigung1 == 0) {
Helligkeit = Helligkeit - 20;
FastLED.setBrightness(Helligkeit);
Serial.println(Helligkeit);
Berechtigung1 = 1;
}
//-----------------------------------------------------------------------------Berechtigung Bedingung
if (results.value != 16726725 ) {
Berechtigung = 0;
}
if (results.value != 16759365) {
Berechtigung1 = 0;
}
//-----------------------------------------------------------------------------Play Pause Taste
//play/pause = cycles through colours
if (results.value == 831890207) {
uint8_t i = beatsin8(130, 0, 150);
fill_solid(leds, NUM_LEDS, CHSV(i, 255, 150));
FastLED.show();
}
//-----------------------------------------------------------------------------BPM 1
if (results.value == 16747125) {
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( 70, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
FastLED.show();
}
//-------------------------------------------------------------------------------------Feuer 1
if (results.value == 16718055) {
CRGBPalette16 palette = HeatColors_p;
uint8_t beat = beatsin8( 50, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
FastLED.show();
}
//--------------------------------------------------------------------------------------Regenbogen
if (results.value == 16718565) {
fill_rainbow( leds, NUM_LEDS, gHue, 2);
FastLED.show();
}
//---------------------------------------------------------------------------------Regenbogen mit glitzer
if (results.value == 16722645) {
fill_rainbow( leds, NUM_LEDS, gHue, 7);
addGlitter(70);
FastLED.show();
}
//--------------------------------------------------------------------------------------- Confetti
if (results.value == 16755285) {
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
FastLED.show();
}
//-----------------------------------------------------------------------------------------Sinelon
if (results.value == 16749165) {
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS - 1 );
leds[pos] += CHSV( gHue, 255, 192);
FastLED.show();
}
//----------------------------------------------------------------------------------------BPM 2
if (results.value == 16716525) {
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
FastLED.show();
}
//-----------------------------------------------------------------------------------------Juggle
if (results.value == 16714485) {
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for ( int i = 0; i < 8; i++) {
leds[beatsin16( i + 7, 0, NUM_LEDS - 1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
FastLED.show();
}
//------------------------------------------------------------------------------------------Kamin
if (results.value == 16753245) {
static byte heat[NUM_LEDS];
for ( int i = 0; i < NUM_LEDS; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
}
for ( int k = NUM_LEDS - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
if ( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160, 255) );
}
for ( int j = 0; j < NUM_LEDS; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if ( gReverseDirection ) {
pixelnumber = (NUM_LEDS - 1) - j;
} else {
pixelnumber = j;
}
leds[pixelnumber] = color;
}
FastLED.show();
}
//----------------------------------------------------------------------------------Nacht mit Glitzer
if (results.value == 16757325) {
fill_gradient_RGB(leds, 0, CHSV(160, 255, 150), NUM_LEDS, CHSV(180, 230, 80));
addGlitter(40);
FastLED.show();
}
//--------------------------------------------------------------------------------------------Regen
if (results.value == 16724685) {
fadeToBlackBy( leds, NUM_LEDS, 30);
int pos = random16(NUM_LEDS);
leds[pos] = CHSV(135, 80, 200);
FastLED.show();
}
//------------------------------------------------------------------------------Säure Regen
if (results.value == 16750695) {
fadeToBlackBy( leds, NUM_LEDS, 40);
int pos = random16(NUM_LEDS);
leds[pos] = CRGB::Green;
FastLED.show();
}
//-------------------------------------------------------------------------------Schnee
if (results.value == 16758855) {
fadeToBlackBy( leds, NUM_LEDS, 30);
addGlitter(50);
FastLED.show();
}
//-------------------------------------------------------------------------------Gewitter
if (results.value == 16742535) {
fadeToBlackBy( leds, NUM_LEDS, 30);
fill_solid(leds, NUM_LEDS, CHSV(0, 0, 50));
addGlitter(60);
lightning();
FastLED.show();
}
//------------------------------------------------------------------------------------Cylon
if (results.value == 16775175) {
static uint8_t hue = 0;
for (int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
Serial.print("x");
for (int i = (NUM_LEDS) - 1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
FastLED.show();
}
//------------------------------------------------------------------------------------Palette Definition
CRGBPalette16 pacifica_palette_1 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x14554B, 0x28AA50
};
CRGBPalette16 pacifica_palette_2 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x0C5F52, 0x19BE5F
};
CRGBPalette16 pacifica_palette_3 =
{ 0x000208, 0x00030E, 0x000514, 0x00061A, 0x000820, 0x000927, 0x000B2D, 0x000C33,
0x000E39, 0x001040, 0x001450, 0x001860, 0x001C70, 0x002080, 0x1040BF, 0x2060FF
};
//---------------------------------------------------------------------------------------------Pacifica
if (results.value == 16751205) {
static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
static uint32_t sLastms = 0;
uint32_t ms = GET_MILLIS();
uint32_t deltams = ms - sLastms;
sLastms = ms;
uint16_t speedfactor1 = beatsin16(3, 179, 269);
uint16_t speedfactor2 = beatsin16(4, 179, 269);
uint32_t deltams1 = (deltams * speedfactor1) / 256;
uint32_t deltams2 = (deltams * speedfactor2) / 256;
uint32_t deltams21 = (deltams1 + deltams2) / 2;
sCIStart1 += (deltams1 * beatsin88(1011, 10, 13));
sCIStart2 -= (deltams21 * beatsin88(777, 8, 11));
sCIStart3 -= (deltams1 * beatsin88(501, 5, 7));
sCIStart4 -= (deltams2 * beatsin88(257, 4, 6));
fill_solid( leds, NUM_LEDS, CRGB( 2, 6, 10));
pacifica_one_layer( pacifica_palette_1, sCIStart1, beatsin16( 3, 11 * 256, 14 * 256), beatsin8( 10, 70, 130), 0 - beat16( 301) );
pacifica_one_layer( pacifica_palette_2, sCIStart2, beatsin16( 4, 6 * 256, 9 * 256), beatsin8( 17, 40, 80), beat16( 401) );
pacifica_one_layer( pacifica_palette_3, sCIStart3, 6 * 256, beatsin8( 9, 10, 38), 0 - beat16(503));
pacifica_one_layer( pacifica_palette_3, sCIStart4, 5 * 256, beatsin8( 8, 10, 28), beat16(601));
pacifica_add_whitecaps();
pacifica_deepen_colors();
FastLED.show();
}
//---------------------------------------------------------------------------------Pride
if (results.value == 16726215) {
static uint16_t sPseudotime = 0;
static uint16_t sLastMillis = 0;
static uint16_t sHue16 = 0;
uint8_t sat8 = beatsin88( 87, 220, 250);
uint8_t brightdepth = beatsin88( 341, 96, 224);
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
uint8_t msmultiplier = beatsin88(147, 23, 60);
uint16_t hue16 = sHue16;//gHue * 256;
uint16_t hueinc16 = beatsin88(113, 1, 3000);
uint16_t ms = millis();
uint16_t deltams = ms - sLastMillis ;
sLastMillis = ms;
sPseudotime += deltams * msmultiplier;
sHue16 += deltams * beatsin88( 400, 5, 9);
uint16_t brightnesstheta16 = sPseudotime;
for ( uint16_t i = 0 ; i < NUM_LEDS; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 / 256;
brightnesstheta16 += brightnessthetainc16;
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
bri8 += (255 - brightdepth);
CRGB newcolor = CHSV( hue8, sat8, bri8);
uint16_t pixelnumber = i;
pixelnumber = (NUM_LEDS - 1) - pixelnumber;
nblend( leds[pixelnumber], newcolor, 64);
}
FastLED.show();
}
//---------------------------------------------------------------------------------Roter Regen
if (results.value == 16734375) {
fadeToBlackBy( leds, NUM_LEDS, 40);
int pos = random16(NUM_LEDS);
leds[pos] = CRGB::Red;
FastLED.show();
}
//---------------------------------------------------------------------------------Blauer Regen
if (results.value == 16767015) {
fadeToBlackBy( leds, NUM_LEDS, 40);
int pos = random16(NUM_LEDS);
leds[pos] = CRGB::Blue;
FastLED.show();
}
}
//Wenn die Zeit abgelaufen ist, zählt der PWM auf 0 runter
else if ((TIME <= 0))
{
FastLED.clear();
FastLED.show();
digitalWrite(PCLED, LOW);
}
//Hier zählt der nur runter, bis die Zeit auf 0 ist
if (( TIME >= 1))
{
TIME--;
}
delay(1);
}
//<——————————————————————OTHER FUNCTIONS————————————————————>
void addGlitter( fract8 chanceOfGlitter)
{ if ( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void lightning ()
{ EVERY_N_MILLISECONDS (4000) {
uint8_t i = beatsin8(6, 0, 255);
fill_solid(leds, NUM_LEDS, CHSV(160, 10, i));
}
}
void fadeall() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i].nscale8(250);
}
}
void pacifica_one_layer( CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
{
uint16_t ci = cistart;
uint16_t waveangle = ioff;
uint16_t wavescale_half = (wavescale / 2) + 20;
for ( uint16_t i = 0; i < NUM_LEDS; i++) {
waveangle += 250;
uint16_t s16 = sin16( waveangle ) + 32768;
uint16_t cs = scale16( s16 , wavescale_half ) + wavescale_half;
ci += cs;
uint16_t sindex16 = sin16( ci) + 32768;
uint8_t sindex8 = scale16( sindex16, 240);
CRGB c = ColorFromPalette( p, sindex8, bri, LINEARBLEND);
leds[i] += c;
}
}
void pacifica_add_whitecaps()
{
uint8_t basethreshold = beatsin8( 9, 55, 65);
uint8_t wave = beat8( 7 );
for ( uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t threshold = scale8( sin8( wave), 20) + basethreshold;
wave += 7;
uint8_t l = leds[i].getAverageLight();
if ( l > threshold) {
uint8_t overage = l - threshold;
uint8_t overage2 = qadd8( overage, overage);
leds[i] += CRGB( overage, overage2, qadd8( overage2, overage2));
}
}
}
void pacifica_deepen_colors()
{
for ( uint16_t i = 0; i < NUM_LEDS; i++) {
leds[i].blue = scale8( leds[i].blue, 145);
leds[i].green = scale8( leds[i].green, 200);
leds[i] |= CRGB( 2, 5, 7);
}
}