So i got a weird Problem and i cant think of something to work around it. I got 9m of WS2811 Led strips hooked up on a Arduino UNO R3. Now i attached a IR Sensor to it (3,3v , GND , Pin 7) that recieves the IR Signals sent from my Remote. Getting it to recieve the Signal itself is no Problem. But if i implement it into a Code that animates my Led Strip, i dont get Serial Prints to my Serial Monitor on COM3.
Following is my Code:
#include "FastLED.h"
#include <IRremote.h>
const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long key_value = 0;
// Variables that remain constant
const byte pinData = A5; // Digital output pin to LED strip
//const byte pinClock = 3; // Digital output pin to LED strip
const byte numLeds = 100; // Number of LEDs
struct CRGB leds[numLeds]; // Declare an array that stores each LED's data
DEFINE_GRADIENT_PALETTE( cw5 ) {
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
0, 255, 60, 0,
235, 122, 35, 45,
255, 169, 98, 90,
};
DEFINE_GRADIENT_PALETTE(auroraBorealis) {
0, 0, 255, 28,
128, 255, 3, 22,
192, 247, 1, 9,
255, 0, 255, 28
};
DEFINE_GRADIENT_PALETTE(cumulusClouds)
{
0, 152, 164, 155,
30, 139, 152, 140,
64, 126, 141, 128,
92, 80, 95, 82,
107, 46, 59, 47,
114, 74, 88, 71,
123, 110, 124, 102,
196, 46, 58, 39,
255, 11, 18, 8
};
// Set the LED strip's overall brightness
byte totalBrightness = 255;
int value;
// Variables that can change
CRGBPalette16 activePalette = cw5; // Select a palette
byte paletteIndex = 0; // Current colour from the selected palette
// Total gradient palette colour transition time in minutes, with 10
// minutes = 2343.75 ms per transition step; 1 hour = 14062.5 ms
const byte transitionDuration = 3;
const byte noiseAmount = 2100; // Higher value = more granular noise
// The smaller the difference between the two values, the more subtle the
// noise's brightness variation will be
const byte minBrightness = 5;
const byte maxBrightness = 255;
void setup()
{
FastLED.addLeds<WS2811, pinData, BRG>(leds, numLeds);
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop(){
{if (irrecv.decode(&results)){
if (results.value == 0XFFFFFFFF)
results.value = key_value;
switch(results.value){
case 0xCE1972FD: //ON
Serial.println("ON");
case 0xD4DD0381: //OFF
Serial.println("OFF");
case 0x8503705D: //Bightness +
Serial.println("Brightness+");
case 0xDEB0C861: //Brightness-
Serial.println("Brightness-");
case 0x9BA392C1: // WHite
Serial.println("White");
case 0xE85952E1: //Red
Serial.println("Red");
case 0x78CDA4DD: //Green
Serial.println("Green");
case 0xA2672345: //Blue
Serial.println("Blue");
case 0xDCC45BE1: //Flash
Serial.println("Flash");
case 0x374E8B9D: //Strobe
Serial.println("Strobe");
case 0xB9C07541: //Fade
Serial.println("Fade");
case 0xA7315F7D: //smooth
Serial.println("Smooth");
case 0xD3FD9A81: //R1
Serial.println("R1")
case 0x84044BBD: //R2
Serial.println("R2");
case 0xB0F9B3E1: //R3
Serial.println("R3");
case 0x9DE75E1D: //R4
Serial.println("R4");
case 0x6471EC7D: //G1
Serial.println("G1");
case 0x14789DB9: //G2
Serial.println("G2");
case 0x416E05DD: //G3
Serial.println("G3");
case 0xF794B621: //G4
Serial.println("G4");
case 0x9D52009D: //B1
Serial.println("B1");
case 0x3E121C21: //B2
Serial.println("B2");
case 0x6A844445: //B3
Serial.println("B3");
case 0x57F52E81: //B4
Serial.println("B4");
}
key_value = results.value;
}
}
// Render the effect into the array leds
paletteTransition();
// Oscillate the overall brightness at a specified BPM, within a range
FastLED.setBrightness(value);
// Display all LED's data (= illuminate the LED strip)
FastLED.show();
irrecv.resume();
}
void paletteTransition()
{
// Calculate gradient palette transition steps (in milliseconds)
static const float interval = ((float)(transitionDuration * 60) / 256) * 10000000;
// Declare a variable that stores the noise (= LED brightness) oscillation
// speed
static uint32_t dist;
// Go through all LEDs in the leds array
for (int i = 0; i < numLeds; i++)
{
// Calculate a Simplex Noise value
int noise = inoise8(dist - i * noiseAmount, dist + i * noiseAmount) % 255;
// Scale the noise value into a 0 - 255 brighntess value range
byte brightness = map(noise, 0, 255, minBrightness, maxBrightness);
// Write a colour fetched from the gradient palette, its brightness
// modified by the noise, to the indexed LED
leds[i] = ColorFromPalette(activePalette, paletteIndex, brightness, LINEARBLEND);
}
// Oscillate the noise's speed at a specified BPM, within a range
dist += beatsin8(2, 2, 2);
EVERY_N_MILLISECONDS(interval)
{
// Select the next colour
if (paletteIndex < 255)
{
paletteIndex++;
}
// Wrap around back to zero at the end (= cycle through palette again)
if (paletteIndex == 255)
{
paletteIndex = 0;
}
}
}
I want to remove the Serial Print part later and replace them with certain Actions. So i can controll Brightness and Color and switch it on and off via Remote.
Could it be that the “Time Window” in where the Arudino could possibly recieve a Signal (via the if (irrecv.decode(&results)) part) is too small and the Signal isnt getting picked up? Cause the Code is too Long ?
(The Code isnt done since i Need to “Connect” the functions like the Case block with each function i Need to add (Like Brightness , Color and stuff. But i first wanna make sure it recieves the Signals before continuing to write this Code and replace stuff)
EDIT:
I noticed that the Signals are somehow getting picked up, but it doesnt run any function other than “irrecv.blink13(true);”
I tried Building up the Code from Nothing and see what function might cause it to not Print the Responds into Serial Monitor. It stops Responding over Serial at FastLed.show();