Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LCD.h>
- #include <LiquidCrystal_I2C.h>
- #define butl 3
- #define butp 5
- #define led 6
- LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
- int button = 0;
- int num;
- int state;
- String names[3]={"Damian", "Krzysztof", "Klaudiusz"};
- void setup()
- {
- pinMode(butl,INPUT);
- pinMode(butp,INPUT);
- pinMode(led,OUTPUT);
- digitalWrite(butl,HIGH);
- digitalWrite(butp,HIGH);
- Serial.begin(9600);
- lcd.begin (16,2); // wyswietlacz 2x16
- lcd.setBacklightPin(3,POSITIVE);
- lcd.setBacklight(HIGH);
- lcd.clear();
- lcd.home();
- lcd.print(names[num]);
- }
- void loop()
- {
- bool butlst=digitalRead(butl);
- bool butpst=digitalRead(butp);
- button = 0;
- if (butlst == 0){
- button=1;
- }
- if (butpst == 0){
- button=2;
- }
- switch(button){
- case 1:
- state=0;
- lcd.clear();
- lcd.home();
- lcd.print(names[num]);
- num++;
- if(num>2){
- num=0;
- }
- break;
- case 2:
- state=1;
- break;
- }
- if(state==1){
- lcd.clear();
- lcd.home();
- lcd.print(names[num]);
- num++;
- if(num>2){
- num=0;
- }
- delay(1000);
- }
- delay(250);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement