Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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 Alert
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-12-05 09:45:44
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Establezca conexión Bluetooth con un módulo ESP32 */
- /* utilizando SoftwareSerial; al perder la señal, */
- /* active un buzzer conectado a un pin digital para */
- /* alertar al usuario. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void checkBluetoothConnection(void);
- /***** DEFINITION OF Software Serial *****/
- const uint8_t pedro_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
- const uint8_t pedro_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
- SoftwareSerial pedro_HC05_mySerial(pedro_HC05_mySerial_PIN_SERIAL_RX_A1, pedro_HC05_mySerial_PIN_SERIAL_TX_A0);
- /***** DEFINITION OF BUZZER PIN *****/
- const uint8_t buzzerPin = 9; // Buzzer connected to digital pin 9
- void setup(void)
- {
- // Initialize serial communication with the Bluetooth module
- pedro_HC05_mySerial.begin(9600);
- // Initialize the buzzer pin as an output
- pinMode(buzzerPin, OUTPUT);
- // Ensure the buzzer is off initially
- digitalWrite(buzzerPin, LOW);
- }
- void loop(void)
- {
- // Check Bluetooth connection status
- checkBluetoothConnection();
- // Add any other main code here
- }
- /***** FUNCTION TO CHECK BLUETOOTH CONNECTION *****/
- void checkBluetoothConnection(void)
- {
- // If no data is available from the Bluetooth module
- if (!pedro_HC05_mySerial.available())
- {
- // Activate the buzzer to alert the user
- digitalWrite(buzzerPin, HIGH); // Turn on buzzer
- }
- else
- {
- // If data is available, turn off the buzzer
- digitalWrite(buzzerPin, LOW); // Turn off buzzer
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement