Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal_I2C.h>
- #include <Wire.h>
- #define maxcars 10
- const int buttonPin1 = 4; // Pin voor drukknop 1 (D4)
- const int buttonPin2 = 5; // Pin voor drukknop 2 (D5)
- int count = 10;
- LiquidCrystal_I2C lcd(0x27, 16, 2); // Initialiseer het LCD-display
- void setup() {
- lcd.begin(16, 2); // Initialiseer het LCD-display met 16 kolommen en 2 rijen
- lcd.backlight(); // Schakel de achtergrondverlichting in
- pinMode(buttonPin1, INPUT_PULLUP); // Drukknop 1 als input met pull-up weerstand
- pinMode(buttonPin2, INPUT_PULLUP); // Drukknop 2 als input met pull-up weerstand
- }
- void text_print(){
- lcd.setCursor(0, 0);
- lcd.print("Count: ");
- lcd.print(count);
- }
- void loop() {
- if(digitalRead(buttonPin1) == LOW && count <= maxcars){
- count++;
- lcd.clear();
- }
- if(digitalRead(buttonPin2) == LOW && count >= 1){
- count--;
- lcd.clear();
- }
- if (count == 0) {
- lcd.setCursor(0, 0);
- lcd.print("VOL! ");
- }else{
- text_print();
- }
- delay(400);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement