CCCPaste

"Infrared Control" rev_01

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: "Infrared Control"
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2024-04-17 20:12:46

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Irremote.h  Fastled    Led pin6   Num leds 184 */
	/* Receiver_pin 2   Brightness 40     all colors with */
	/* remote   and a cycling ledstrip code that you can */
	/* override with the ir  with serial monitor */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include    // https://github.com/Arduino-IRremote/Arduino-IRremote
#include     // https://github.com/FastLED/FastLED

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void updateOutputs(void); // Added function prototype

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t ir_PIN_D2 = 2;

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t ledstrip_PIN_D6 = 6;

/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool ledstrip_PIN_D6_rawData = 0;

/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float ledstrip_PIN_D6_phyData = 0.0;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
IRrecv irrecv(ir_PIN_D2);   // Create an instance of the IRrecv class
decode_results results;     // Create a variable to store the IR decoding results

CRGB leds[184];   // Create an array to store the LED strip data

void setup(void)
{
    // put your setup code here, to run once:

    pinMode(ir_PIN_D2, INPUT);
    pinMode(ledstrip_PIN_D6, OUTPUT);

    irrecv.enableIRIn();    // Enable IR reception

    FastLED.addLeds(leds, 184);   // Initialize FastLED library with the LED strip

    FastLED.setBrightness(40);   // Set the LED strip brightness to 40

    for (int i = 0; i < 184; i++) {
        leds[i] = CRGB::Black;   // Turn off all LEDs initially
    }

    FastLED.show();   // Update LED strip with initial data
}

void loop(void)
{
    // put your main code here, to run repeatedly:

    updateOutputs(); // Refresh output data

    if (irrecv.decode(&results))    // Check if IR signal is received
    {
        // Process the received IR signal here
        irrecv.resume();    // Continue to receive IR signals
    }
}

void updateOutputs()
{
    for (int i = 0; i < 184; i++) {
        leds[i] = CRGB::White;   // Set all LEDs to white
    }

    FastLED.show();   // Update LED strip with the new data
}