/********* 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: "LED Control" - Source Code NOT compiled for: Arduino Uno - Source Code created on: 2024-11-19 14:24:49 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* if typed 1 in terminal then led turns on and if */ /* typed 0 it goes off */ /****** END SYSTEM REQUIREMENTS *****/ /* START CODE */ /****** DEFINITION OF LIBRARIES *****/ #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); // Added function prototype for updateOutputs /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t dede_LED_PIN_D2 = 2; const int ledPin = 13; // Added USER CODE for another LED pin /***** DEFINITION OF Software Serial *****/ const uint8_t blueblue_HC05_mySerial_PIN_SERIAL_TX_A0 = A0; const uint8_t blueblue_HC05_mySerial_PIN_SERIAL_RX_A1 = A1; SoftwareSerial blueblue_HC05_mySerial(blueblue_HC05_mySerial_PIN_SERIAL_RX_A1, blueblue_HC05_mySerial_PIN_SERIAL_TX_A0); /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool dede_LED_PIN_D2_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float dede_LED_PIN_D2_phyData = 0.0; void setup(void) { // put your setup code here, to run once: pinMode(dede_LED_PIN_D2, OUTPUT); pinMode(ledPin, OUTPUT); // Set up the additional LED pin blueblue_HC05_mySerial.begin(9600); Serial.begin(9600); // Set baud rate to 9600 for Serial communication (added from USER CODE) } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data if (Serial.available() > 0) { // Added from USER CODE char data = Serial.read(); // Read data from Serial if (data == '1') { digitalWrite(ledPin, HIGH); // Turn additional LED on } else if (data == '0') { digitalWrite(ledPin, LOW); // Turn additional LED off } } } void updateOutputs() { digitalWrite(dede_LED_PIN_D2, dede_LED_PIN_D2_rawData); } /* END CODE */