Advertisement
pleasedontcode

Button Display rev_04

Jan 28th, 2024
65
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 Display
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2024-01-28 17:18:19
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* On LCD1602_LCD1602I2C_I2C display   on the first */
  21.     /* line: CZERWONY "+resultC"  on the second line: */
  22.     /* ZOLTY "+resultZ"  the initial value of resultC and */
  23.     /* resultZ is 10000. */
  24. /****** SYSTEM REQUIREMENT 2 *****/
  25.     /* Holding down the czerwonyP subtracts from the */
  26.     /* resultC. Holding down the zielonyP subtracts from */
  27.     /* the resultZ. Holding time subtracts value:  1 */
  28.     /* second subtracts 10, each subsequent second */
  29.     /* doubles the value until the button is released. */
  30. /****** END SYSTEM REQUIREMENTS *****/
  31.  
  32. /****** DEFINITION OF LIBRARIES *****/
  33. #include <Arduino.h>
  34. #include <Wire.h>
  35. #include <EasyButton.h>
  36. #include <LiquidCrystal_I2C.h>
  37.  
  38. /****** FUNCTION PROTOTYPES *****/
  39. void setup(void);
  40. void loop(void);
  41.  
  42. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  43. const uint8_t zielonyP_PushButton_PIN_D2 = 2;
  44. const uint8_t czerwonyP_PushButton_PIN_D3 = 3;
  45.  
  46. /***** DEFINITION OF I2C PINS *****/
  47. const uint8_t LCD1602_LCD1602I2C_I2C_PIN_SDA_A4 = A4;
  48. const uint8_t LCD1602_LCD1602I2C_I2C_PIN_SCL_A5 = A5;
  49. const uint8_t LCD1602_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // Replace with the correct I2C slave address
  50.  
  51. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  52. EasyButton zielonyP_PushButton(zielonyP_PushButton_PIN_D2);
  53. EasyButton czerwonyP_PushButton(czerwonyP_PushButton_PIN_D3);
  54. LiquidCrystal_I2C lcd(LCD1602_LCD1602I2C_I2C_SLAVE_ADDRESS, LCD1602_LCD1602I2C_I2C_PIN_SDA_A4, LCD1602_LCD1602I2C_I2C_PIN_SCL_A5);
  55.  
  56. // System Requirement 1: Display initial values of resultC and resultZ on LCD1602
  57. int resultC = 10000;
  58. int resultZ = 10000;
  59.  
  60. void setup(void)
  61. {
  62.   // Put your setup code here, to run once:
  63.   zielonyP_PushButton.begin();
  64.   czerwonyP_PushButton.begin();
  65.  
  66.   pinMode(zielonyP_PushButton_PIN_D2, INPUT_PULLUP);
  67.   pinMode(czerwonyP_PushButton_PIN_D3, INPUT_PULLUP);
  68.  
  69.   lcd.begin(16, 2);
  70.  
  71.   // Display initial values on LCD1602
  72.   lcd.setCursor(0, 0);
  73.   lcd.print("CZERWONY ");
  74.   lcd.print(resultC);
  75.  
  76.   lcd.setCursor(0, 1);
  77.   lcd.print("ZOLTY ");
  78.   lcd.print(resultZ);
  79. }
  80.  
  81. void loop(void)
  82. {
  83.   // Put your main code here, to run repeatedly:
  84.   zielonyP_PushButton.read();
  85.   czerwonyP_PushButton.read();
  86. }
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement