/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Button Display - Source Code compiled for: Arduino Nano - Source Code created on: 2024-01-28 17:18:19 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* On LCD1602_LCD1602I2C_I2C display on the first */ /* line: CZERWONY "+resultC" on the second line: */ /* ZOLTY "+resultZ" the initial value of resultC and */ /* resultZ is 10000. */ /****** SYSTEM REQUIREMENT 2 *****/ /* Holding down the czerwonyP subtracts from the */ /* resultC. Holding down the zielonyP subtracts from */ /* the resultZ. Holding time subtracts value: 1 */ /* second subtracts 10, each subsequent second */ /* doubles the value until the button is released. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t zielonyP_PushButton_PIN_D2 = 2; const uint8_t czerwonyP_PushButton_PIN_D3 = 3; /***** DEFINITION OF I2C PINS *****/ const uint8_t LCD1602_LCD1602I2C_I2C_PIN_SDA_A4 = A4; const uint8_t LCD1602_LCD1602I2C_I2C_PIN_SCL_A5 = A5; const uint8_t LCD1602_LCD1602I2C_I2C_SLAVE_ADDRESS = 0x27; // Replace with the correct I2C slave address /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ EasyButton zielonyP_PushButton(zielonyP_PushButton_PIN_D2); EasyButton czerwonyP_PushButton(czerwonyP_PushButton_PIN_D3); LiquidCrystal_I2C lcd(LCD1602_LCD1602I2C_I2C_SLAVE_ADDRESS, LCD1602_LCD1602I2C_I2C_PIN_SDA_A4, LCD1602_LCD1602I2C_I2C_PIN_SCL_A5); // System Requirement 1: Display initial values of resultC and resultZ on LCD1602 int resultC = 10000; int resultZ = 10000; void setup(void) { // Put your setup code here, to run once: zielonyP_PushButton.begin(); czerwonyP_PushButton.begin(); pinMode(zielonyP_PushButton_PIN_D2, INPUT_PULLUP); pinMode(czerwonyP_PushButton_PIN_D3, INPUT_PULLUP); lcd.begin(16, 2); // Display initial values on LCD1602 lcd.setCursor(0, 0); lcd.print("CZERWONY "); lcd.print(resultC); lcd.setCursor(0, 1); lcd.print("ZOLTY "); lcd.print(resultZ); } void loop(void) { // Put your main code here, to run repeatedly: zielonyP_PushButton.read(); czerwonyP_PushButton.read(); }