/********* 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: Bluetooth Communication
- Source Code NOT compiled for: Arduino Nano ESP32
- Source Code created on: 2024-08-18 07:23:03
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Develop a setup function to initialize the HC-05 */
/* Bluetooth module for reliable data transmission */
/* and a loop function for continuous operation in an */
/* Arduino environment. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/plerup/espsoftwareserial
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/***** DEFINITION OF Software Serial *****/
const uint8_t dd_HC05_mySerial_PIN_SERIAL_TX_A0 = A0; // Define TX pin for HC-05
const uint8_t dd_HC05_mySerial_PIN_SERIAL_RX_A1 = A1; // Define RX pin for HC-05
EspSoftwareSerial::UART dd_HC05_mySerial; // Create an instance of SoftwareSerial
void setup(void)
{
// Initialize the serial communication for HC-05 Bluetooth module
dd_HC05_mySerial.begin(9600, SWSERIAL_8N1, dd_HC05_mySerial_PIN_SERIAL_RX_A1, dd_HC05_mySerial_PIN_SERIAL_TX_A0, false);
// Optional: Start the Serial Monitor for debugging
Serial.begin(9600); // Start the hardware serial for debugging
Serial.println("HC-05 Bluetooth Module Initialized");
}
void loop(void)
{
// Continuously check if data is available from the HC-05
if (dd_HC05_mySerial.available()) {
char receivedChar = dd_HC05_mySerial.read(); // Read the incoming data
Serial.print("Received: "); // Print received data to Serial Monitor
Serial.println(receivedChar);
}
// Optional: Send a test message to the HC-05
// Uncomment the following lines to send data periodically
/*
dd_HC05_mySerial.println("Hello from Arduino!"); // Send a test message
delay(1000); // Wait for 1 second before sending again
*/
}
/* END CODE */