Advertisement
Guest User

1

a guest
Feb 24th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LCD.h>
  3. #include <LiquidCrystal_I2C.h>
  4. #define butl 3
  5. #define butp 5
  6. #define led 6
  7. LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);
  8. int button = 0;
  9. int num;
  10. int state;
  11. String names[3]={"Damian", "Krzysztof", "Klaudiusz"};
  12. void setup()
  13. {
  14.  
  15.   pinMode(butl,INPUT);
  16.   pinMode(butp,INPUT);
  17.  
  18.   pinMode(led,OUTPUT);
  19.   digitalWrite(butl,HIGH);
  20.   digitalWrite(butp,HIGH);
  21.   Serial.begin(9600);
  22.  
  23.   lcd.begin (16,2); // wyswietlacz 2x16
  24.   lcd.setBacklightPin(3,POSITIVE);
  25.   lcd.setBacklight(HIGH);
  26.   lcd.clear();
  27.   lcd.home();
  28.   lcd.print(names[num]);
  29.  
  30.  
  31. }
  32.  
  33. void loop()
  34. {
  35. bool  butlst=digitalRead(butl);
  36. bool  butpst=digitalRead(butp);
  37.  
  38. button = 0;
  39. if (butlst == 0){
  40.   button=1;
  41. }
  42.  
  43. if (butpst == 0){
  44.   button=2;
  45. }
  46.  
  47.  
  48.  
  49. switch(button){
  50.   case 1:
  51.   state=0;
  52.  lcd.clear();
  53.  lcd.home();
  54.  lcd.print(names[num]);
  55.  num++;
  56.  if(num>2){
  57.   num=0;
  58.   }
  59.       break;
  60.   case 2:
  61.      
  62. state=1;
  63.       break;
  64. }
  65. if(state==1){
  66.   lcd.clear();
  67.  lcd.home();
  68.  lcd.print(names[num]);
  69.  num++;
  70.   if(num>2){
  71.   num=0;
  72.   }
  73.   delay(1000);
  74. }
  75.  
  76.  
  77.  
  78. delay(250);
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement