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: Button Monitor
- - Source Code compiled for: Arduino Nano
- - Source Code created on: 2023-12-19 01:16:07
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Convert an int variable 1234 in string and print */
- /* on serial monitor */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <EasyButton.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Button_PushButton_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- EasyButton button(Button_PushButton_PIN_D2); // Create an instance of EasyButton
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(9600); // Initialize serial communication
- pinMode(Button_PushButton_PIN_D2, INPUT_PULLUP);
- button.begin(); // Initialize the button
- button.onPressed([]() {
- // This function will be called when the button is pressed
- Serial.println("Button has been pressed");
- });
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- button.read(); // Read the button state
- // System Requirement 1: Convert an int variable 1234 to a string and print it on the serial monitor
- int num = 1234;
- char str[10];
- sprintf(str, "%d", num);
- Serial.println(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement