/********* 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: "Random Blink" - Source Code compiled for: Arduino Mega - Source Code created on: 2024-04-06 22:51:46 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* all pins low PoleR PoleG PoleB Blink ransomly */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t PoleR_LED_PIN_D2 = 2; const uint8_t PoleG_LED_PIN_D3 = 3; const uint8_t PoleB_LED_PIN_D4 = 4; const uint8_t PoleON_LED_PIN_D5 = 5; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ bool PoleR_LED_PIN_D2_rawData = 0; bool PoleG_LED_PIN_D3_rawData = 0; bool PoleB_LED_PIN_D4_rawData = 0; bool PoleON_LED_PIN_D5_rawData = 0; void setup(void) { // put your setup code here, to run once: pinMode(PoleR_LED_PIN_D2, OUTPUT); pinMode(PoleG_LED_PIN_D3, OUTPUT); pinMode(PoleB_LED_PIN_D4, OUTPUT); pinMode(PoleON_LED_PIN_D5, OUTPUT); } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data // Implement System Requirement 1: Set all pins low, then randomly blink them digitalWrite(PoleR_LED_PIN_D2, LOW); digitalWrite(PoleG_LED_PIN_D3, LOW); digitalWrite(PoleB_LED_PIN_D4, LOW); digitalWrite(PoleON_LED_PIN_D5, LOW); delay(500); // Wait for 500ms // Generate random numbers between 0 and 1 PoleR_LED_PIN_D2_rawData = random(2); PoleG_LED_PIN_D3_rawData = random(2); PoleB_LED_PIN_D4_rawData = random(2); PoleON_LED_PIN_D5_rawData = random(2); delay(500); // Wait for 500ms } void updateOutputs() { digitalWrite(PoleR_LED_PIN_D2, PoleR_LED_PIN_D2_rawData); digitalWrite(PoleG_LED_PIN_D3, PoleG_LED_PIN_D3_rawData); digitalWrite(PoleB_LED_PIN_D4, PoleB_LED_PIN_D4_rawData); digitalWrite(PoleON_LED_PIN_D5, PoleON_LED_PIN_D5_rawData); }