/********* 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: friday - Source Code compiled for: Arduino Uno - Source Code created on: 2023-11-16 13:35:00 - Source Code generated by: IRJM ********* Pleasedontcode.com **********/ /****** DEFINITION OF LIBRARIES *****/ #include #include /****** SYSTEM REQUIREMENT 1 *****/ /* Turn off Led when HC05 is below 20cm */ /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t LED_PIN_D2 = 2; /***** DEFINITION OF Software Serial *****/ const uint8_t HC05_mySerial_PIN_SERIAL_TX_A0 = A0; const uint8_t HC05_mySerial_PIN_SERIAL_RX_A1 = A1; SoftwareSerial HC05_mySerial(HC05_mySerial_PIN_SERIAL_RX_A1, HC05_mySerial_PIN_SERIAL_TX_A0); void setup(void) { // put your setup code here, to run once: pinMode(LED_PIN_D2, OUTPUT); HC05_mySerial.begin(9600); } void loop(void) { // put your main code here, to run repeatedly: // Read the distance from HC05 int distance = HC05_mySerial.read(); // Check if the distance is below 20cm if (distance < 20) { // Turn off the LED digitalWrite(LED_PIN_D2, LOW); } else { // Turn on the LED digitalWrite(LED_PIN_D2, HIGH); } }