CCCPaste

RGB LED Control rev_02

/********* 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: RGB LED Control
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2024-05-02 09:36:55

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* The system control an RGB LED and a piezo using */
	/* Arduino UNO.A short press on the push button (less */
	/* than 300ms) shall change the RGB status in a */
	/* sequence of: dimmed, red, green, blue. A long */
	/* press and release (more than 500ms) shall trigger */
	/* the piezo. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 	//https://github.com/evert-arias/EasyButton

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void updateOutputs(void);

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

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t myRgb_LEDRGB_Red_PIN_D4 = 4;
const uint8_t myRgb_LEDRGB_Green_PIN_D5 = 5;
const uint8_t myRgb_LEDRGB_Blue_PIN_D6 = 6;

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

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

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/

// Instance of the button.
EasyButton button(myButton_PushButton_PIN_D2);

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

	pinMode(myButton_PushButton_PIN_D2, INPUT_PULLUP);

	pinMode(myRgb_LEDRGB_Red_PIN_D4, OUTPUT);
	pinMode(myRgb_LEDRGB_Green_PIN_D5, OUTPUT);
	pinMode(myRgb_LEDRGB_Blue_PIN_D6, OUTPUT);

}

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

	updateOutputs(); // Refresh output data

}

void updateOutputs(void)
{
	digitalWrite(myRgb_LEDRGB_Red_PIN_D4, myRgb_LEDRGB_Red_PIN_D4_rawData);
	digitalWrite(myRgb_LEDRGB_Green_PIN_D5, myRgb_LEDRGB_Green_PIN_D5_rawData);
	digitalWrite(myRgb_LEDRGB_Blue_PIN_D6, myRgb_LEDRGB_Blue_PIN_D6_rawData);
}