Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* 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 Control - Source Code compiled for: Arduino Nano - Source Code created on: 2024-01-28 16:52:47 ********* 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_PushButton subtracts */ /* from the resultC. Holding down the */ /* zielonyP_PushButton subtracts from the resultZ. */ /* Length of hold subtracts value: 1 second subtracts */ /* 10, 5 seconds subtracts 50, 10 seconds subtracts */ /* 100. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
#include
#include
/****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateDisplay(int resultC, int resultZ); void onPressedForZielonyP(); void onPressedForCzerwonyP(); /***** 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 = 39; /****** 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, 16, 2); // Initialize the LiquidCrystal_I2C object int resultC = 10000; // Initial value of resultC int resultZ = 10000; // Initial value of resultZ void setup(void) { // put your setup code here, to run once: pinMode(zielonyP_PushButton_PIN_D2, INPUT_PULLUP); pinMode(czerwonyP_PushButton_PIN_D3, INPUT_PULLUP); lcd.begin(16, 2); // Initialize the LCD // Initialize the button objects zielonyP_PushButton.begin(); czerwonyP_PushButton.begin(); // Attach the callback functions for onPressedFor zielonyP_PushButton.onPressedFor(1000, onPressedForZielonyP); czerwonyP_PushButton.onPressedFor(1000, onPressedForCzerwonyP); // Update the display with the initial values updateDisplay(resultC, resultZ); } void loop(void) { // put your main code here, to run repeatedly: // Continuously read the status of the buttons zielonyP_PushButton.read(); czerwonyP_PushButton.read(); } void onPressedForZielonyP() { resultZ -= 10; updateDisplay(resultC, resultZ); delay(100); // Delay for debounce } void onPressedForCzerwonyP() { resultC -= 10; updateDisplay(resultC, resultZ); delay(100); // Delay for debounce } void updateDisplay(int resultC, int resultZ) { lcd.clear(); // Clear the LCD display lcd.setCursor(0, 0); // Set the cursor to the first line lcd.print("CZERWONY +"); // Print the text for resultC lcd.print(resultC); lcd.setCursor(0, 1); // Set the cursor to the second line lcd.print("ZOLTY +"); // Print the text for resultZ lcd.print(resultZ); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)