Advertisement
pleasedontcode

carracinggame rev_01

Nov 22nd, 2023
77
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: carracinggame
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2023-11-23 04:20:22
  15.     - Source Code generated by: jeffrin
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <EasyButton.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. const uint8_t lightPin = 13; // Pin connected to the light
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  30. const uint8_t mybutton_PushButton_PIN_D2 = 2;
  31.  
  32. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  33. EasyButton myButton(mybutton_PushButton_PIN_D2); // Instance of the EasyButton class
  34.  
  35. void setup(void)
  36. {
  37.   // put your setup code here, to run once:
  38.   pinMode(lightPin, OUTPUT); // Set the light pin as output
  39.   pinMode(mybutton_PushButton_PIN_D2, INPUT_PULLUP);
  40.  
  41.   myButton.begin(); // Initialize the button
  42. }
  43.  
  44. void loop(void)
  45. {
  46.   // put your main code here, to run repeatedly:
  47.   myButton.read(); // Read the button state
  48.  
  49.   // Check if the button is pressed
  50.   if (myButton.isPressed()) {
  51.     // Turn off the light
  52.     digitalWrite(lightPin, LOW);
  53.   } else {
  54.     // Turn on the light
  55.     digitalWrite(lightPin, HIGH);
  56.   }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement