Advertisement
pleasedontcode

Button Logic rev_01

Mar 5th, 2024
66
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: Button Logic
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-05 13:28:59
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Obstacle Avoidance Code */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  25.  
  26. /****** FUNCTION PROTOTYPES *****/
  27. void setup(void);
  28. void loop(void);
  29. void obstacleAvoidance(void);
  30.  
  31. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  32. const uint8_t mybutton_PushButton_PIN_D2 = 2;
  33.  
  34. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  35. EasyButton myButton(mybutton_PushButton_PIN_D2); // Create an instance of EasyButton
  36.  
  37. void setup(void)
  38. {
  39.   // put your setup code here, to run once:
  40.   pinMode(mybutton_PushButton_PIN_D2, INPUT_PULLUP);
  41.  
  42.   myButton.begin(); // Initialize the EasyButton object
  43. }
  44.  
  45. void loop(void)
  46. {
  47.   // put your main code here, to run repeatedly:
  48.   myButton.read(); // Read the state of the button
  49.  
  50.   // Add your code here to respond to button events
  51.   obstacleAvoidance();
  52. }
  53.  
  54. void obstacleAvoidance()
  55. {
  56.   // Add your code here for obstacle avoidance logic
  57.   // This is where you would implement the obstacle avoidance algorithm
  58.   // Use the sensor inputs and control the motor outputs to avoid obstacles
  59.   // You can add code to move the robot, sense the environment, and take appropriate actions
  60.   // For example, you can use ultrasonic sensors to detect obstacles and change the robot's direction
  61.   // You can also use the button as a trigger to start or stop the obstacle avoidance behavior
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement