Advertisement
pleasedontcode

KidsGames_v1 rev_01

Oct 19th, 2023
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: KidsGames_v1
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-10-20 04:08:51
  15.     - Source Code generated by: Anthony
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** FUNCTION PROTOTYPES *****/
  23. void setup(void);
  24. void loop(void);
  25. void onWallJumpButtonPressed(void);
  26.  
  27. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  28. const uint8_t Spacebar_PushButton_PIN_D2 = 2;
  29.  
  30. /****** SYSTEM REQUIREMENT 1 *****/
  31. /* Jump on and off the wall, Pushbutton */
  32. EasyButton wallJumpButton(Spacebar_PushButton_PIN_D2);
  33.  
  34. /****** SYSTEM REQUIREMENT 2 *****/
  35. /* Jump on and off the wall, Pushbutton */
  36. bool isOnWall = false;
  37.  
  38. void setup(void)
  39. {
  40.   // put your setup code here, to run once:
  41.   pinMode(Spacebar_PushButton_PIN_D2, INPUT_PULLUP);
  42.  
  43.   // Initialize the wall jump button
  44.   wallJumpButton.begin();
  45.   wallJumpButton.onPressed(onWallJumpButtonPressed);
  46. }
  47.  
  48. void loop(void)
  49. {
  50.   // put your main code here, to run repeatedly:
  51.   wallJumpButton.read();
  52. }
  53.  
  54. void onWallJumpButtonPressed(void)
  55. {
  56.   // Toggle the state of the wall
  57.   isOnWall = !isOnWall;
  58.  
  59.   // Perform the desired action based on the wall state
  60.   if (isOnWall)
  61.   {
  62.     // Jump off the wall
  63.     Serial.println("Jumping off the wall");
  64.   }
  65.   else
  66.   {
  67.     // Jump on the wall
  68.     Serial.println("Jumping on the wall");
  69.   }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement