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 Button"
- - Source Code NOT compiled for: Arduino Nano ESP32
- - Source Code created on: 2025-01-25 09:51:14
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Que cuando pulse el Mypush que mediante Bluetooth */
- /* haga de teclado y escriba 1234567 */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- #include <BluetoothSerial.h> // Include Bluetooth Serial library
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Mypush_PushButton_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(Mypush_PushButton_PIN_D2); // Create an instance of the EasyButton
- BluetoothSerial SerialBT; // Create an instance of the Bluetooth Serial
- /****** CALLBACK FUNCTION *****/
- void onPressed() {
- SerialBT.println("1234567"); // Send the string "1234567" via Bluetooth
- }
- void setup(void) {
- // put your setup code here, to run once:
- Serial.begin(115200); // Initialize Serial for debugging
- SerialBT.begin("ESP32_BT"); // Initialize Bluetooth with a name
- pinMode(Mypush_PushButton_PIN_D2, INPUT_PULLUP);
- // Initialize the button
- button.begin();
- button.onPressed(onPressed); // Attach the onPressed callback
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- button.read(); // Continuously read the status of the button
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement