Advertisement
pleasedontcode

"Button Game" rev_01

Apr 10th, 2024
153
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 Game"
  13.     - Source Code compiled for: Arduino Mega
  14.     - Source Code created on: 2024-04-10 23:29:11
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* button1=1 button2=2 button3=3 theres 2 players, */
  21.     /* starts with player 1, when they push 3 buttons */
  22.     /* their values are added up and displayed on the top */
  23.     /* row on the LCD, then its player 2s turn when they */
  24.     /* push 3 buttons their score gets added put on */
  25.     /* bottom */
  26. /****** SYSTEM REQUIREMENT 2 *****/
  27.     /* button1=1 button2=2 button3=3 theres 2 players, */
  28.     /* starts with player 1, when they push 3 buttons */
  29.     /* their values are added up and displayed on the top */
  30.     /* row on the LCD, then its player 2s turn when they */
  31.     /* push 3 buttons their score gets added put on */
  32.     /* bottom */
  33. /****** END SYSTEM REQUIREMENTS *****/
  34.  
  35. /****** DEFINITION OF LIBRARIES *****/
  36. #include <Wire.h>
  37. #include <EasyButton.h>
  38. #include <LiquidCrystal_I2C.h>
  39.  
  40. /****** SYSTEM REQUIREMENTS *****/
  41. /****** SYSTEM REQUIREMENT 1 *****/
  42. /* button1=1 button2=2 button3=3 theres 2 players, */
  43. /* starts with player 1, when they push 3 buttons */
  44. /* their values are added up and displayed on the top */
  45. /* row on the LCD, then its player 2s turn when they */
  46. /* push 3 buttons their score gets added put on */
  47. /* bottom */
  48. /****** SYSTEM REQUIREMENT 2 *****/
  49. /* button1=1 button2=2 button3=3 theres 2 players, */
  50. /* starts with player 1, when they push 3 buttons */
  51. /* their values are added up and displayed on the top */
  52. /* row on the LCD, then its player 2s turn when they */
  53. /* push 3 buttons their score gets added put on */
  54. /* bottom */
  55. /****** END SYSTEM REQUIREMENTS *****/
  56.  
  57. /****** FUNCTION PROTOTYPES *****/
  58. void setup(void);
  59. void loop(void);
  60.  
  61. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  62. const uint8_t Button1_PushButton_PIN_D2 = 2;
  63. const uint8_t Button2_PushButton_PIN_D4 = 4;
  64. const uint8_t Button3_PushButton_PIN_D3 = 3;
  65.  
  66. /***** DEFINITION OF I2C PINS *****/
  67. const uint8_t LCD_LCD1602I2C_I2C_PIN_SDA_D20 = 20;
  68. const uint8_t LCD_LCD1602I2C_I2C_PIN_SCL_D21 = 21;
  69. const uint8_t LCD_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27;
  70.  
  71. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  72. EasyButton button1(Button1_PushButton_PIN_D2);
  73. EasyButton button2(Button2_PushButton_PIN_D4);
  74. EasyButton button3(Button3_PushButton_PIN_D3);
  75.  
  76. LiquidCrystal_I2C lcd(LCD_LCD1602I2C_I2C_SLAVE_ADDRESS, LCD_LCD1602I2C_I2C_PIN_SDA_D20, LCD_LCD1602I2C_I2C_PIN_SCL_D21);
  77.  
  78. void setup(void)
  79. {
  80.     // put your setup code here, to run once:
  81.     pinMode(Button1_PushButton_PIN_D2, INPUT_PULLUP);
  82.     pinMode(Button2_PushButton_PIN_D4, INPUT_PULLUP);
  83.     pinMode(Button3_PushButton_PIN_D3, INPUT_PULLUP);
  84.  
  85.     lcd.begin(16, 2);
  86.     lcd.setBacklight(LOW);
  87. }
  88.  
  89. void loop(void)
  90. {
  91.     // put your main code here, to run repeatedly:
  92.     button1.read();
  93.     button2.read();
  94.     button3.read();
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement