Advertisement
Guest User

2

a guest
Feb 24th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 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 nume;
  11. int state;
  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("Technikum nr 1");
  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.  num++;
  52.  if(num>2){
  53.   num=0;
  54.   }
  55.       break;
  56.   case 2:
  57.  nume++;
  58.  if(nume>1){
  59.   nume=0; }    
  60.       break;
  61.  
  62.  
  63. }
  64. switch(num){
  65.   case 0:
  66.   break;
  67.   case 1:
  68.   delay(250);
  69.   break;
  70.   case 2:
  71.   delay(750);
  72.   break;
  73. }
  74. switch(nume){
  75.   case 0:
  76.   lcd.scrollDisplayLeft();
  77.   break;
  78.   case 1:
  79.   lcd.scrollDisplayRight();
  80.   break;
  81. }
  82.  
  83.  
  84. delay(250);
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement