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: KidsGames_v1
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2023-10-20 04:08:51
- - Source Code generated by: Anthony
- ********* Pleasedontcode.com **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Arduino.h>
- #include <EasyButton.h>
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void onWallJumpButtonPressed(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t Spacebar_PushButton_PIN_D2 = 2;
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Jump on and off the wall, Pushbutton */
- EasyButton wallJumpButton(Spacebar_PushButton_PIN_D2);
- /****** SYSTEM REQUIREMENT 2 *****/
- /* Jump on and off the wall, Pushbutton */
- bool isOnWall = false;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(Spacebar_PushButton_PIN_D2, INPUT_PULLUP);
- // Initialize the wall jump button
- wallJumpButton.begin();
- wallJumpButton.onPressed(onWallJumpButtonPressed);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- wallJumpButton.read();
- }
- void onWallJumpButtonPressed(void)
- {
- // Toggle the state of the wall
- isOnWall = !isOnWall;
- // Perform the desired action based on the wall state
- if (isOnWall)
- {
- // Jump off the wall
- Serial.println("Jumping off the wall");
- }
- else
- {
- // Jump on the wall
- Serial.println("Jumping on the wall");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement