• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Kilka "stron" LCD
#23
nie wiem czemu ci ie kompiluje ? tu masz enkoder wrzucony do głównego programu




Kod:
#include <ShiftRegLCD123.h>
ShiftRegLCD123 srlcd( 7, 6, SRLCD123);

#define EncoderA 2
#define EncoderB 3
#define EncoderC 5
    
     int enc = 0;
        
int strona = 1;
int trzymaj = 1;
int lcd = 1;
int x = 0;

void setup() {

Serial.begin(9600);          
srlcd.begin(16,2);              
pinMode(10, INPUT_PULLUP);          
pinMode(11, INPUT_PULLUP);
pinMode(EncoderA, INPUT_PULLUP);          
pinMode(EncoderB, INPUT_PULLUP);
pinMode(EncoderC, INPUT_PULLUP);

}

void loop() {
  
  enc = 0;

     while ( digitalRead(EncoderA) == LOW ){
     if ( digitalRead(EncoderB) == LOW ){
     enc = 1;}}
     while ( digitalRead(EncoderB) == LOW ){
     if ( digitalRead(EncoderA) == LOW ){
     enc = -1;}}
    
  if ( digitalRead(11) == LOW ){trzymaj = strona;strona = 100;delay(250);}
  if ( digitalRead(10) == LOW ){strona++;delay(250);}
  if ( strona > 5 and strona != 100 )strona = 1;
  if ( strona < 1 and strona != 100 )strona = 5;
  x = enc + x ;
  LCD();

  
}
  
  void LCD(){
  
   switch (strona) {
  
   case 1:      
    
   if (lcd != 1){srlcd.clear();lcd = 1;} //czyszczenie ekranu 1

      srlcd.setCursor(0,0);      
      srlcd.print("lcd 1 ");
      srlcd.setCursor(0,1);
      srlcd.print(x);
      srlcd.print("   ");
      break;

   case 2:      
    
    if (lcd != 2){srlcd.clear();lcd = 2;} //czyszczenie ekranu 2
    
      srlcd.setCursor(0,0);      
      srlcd.print("lcd 2 ");
      srlcd.setCursor(0,1);
      srlcd.print(x);
      break;
    
   case 3:    
    
      if (lcd != 3){srlcd.clear();lcd = 3;} //czyszczenie ekranu 3

      srlcd.setCursor(0,0);      
      srlcd.print("lcd 3 ");
      srlcd.setCursor(0,1);
      srlcd.print(x);
      break;
  
   case 4:      
  
      if (lcd != 4){srlcd.clear();lcd = 4;} //czyszczenie ekranu 4
        
      srlcd.setCursor(0,0);      
      srlcd.print("lcd 4 ");
      srlcd.setCursor(0,1);
      srlcd.print(x);
      break;

   case 5:      

    if (lcd != 5){srlcd.clear();lcd = 5;} //czyszczenie ekranu 5

      srlcd.setCursor(0,0);      
      srlcd.print("lcd 5 ");
      srlcd.setCursor(0,1);
      srlcd.print(x);
      break;
      
    case 100:      

    if (lcd != 100){srlcd.clear();lcd = 100;} //czyszczenie ekranu 100

    for ( int x = 0; x < 10; x++ ){

      srlcd.setCursor(2,0);      
      srlcd.print("alarm 100 ");
      srlcd.setCursor(2,1);
      srlcd.print("alarm 100 ");
      delay(250);
      srlcd.setCursor(2,0);      
      srlcd.print("          ");
      srlcd.setCursor(2,1);
      srlcd.print("          ");
      delay(250);
    }
      strona = trzymaj;
      break;  
   }  
}
Ważne aby robić co się lubi albo lubić co się robi .
Arduino UNO, TINY, PRO MINI
Pomoc nagradzamy punktami reputacji Wink
 
Odpowiedź
  


Wiadomości w tym wątku
Kilka "stron" LCD - przez shalvan - 19-09-2015, 17:50
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 00:11
RE: Kilka "stron" LCD - przez shalvan - 20-09-2015, 09:29
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 10:38
RE: Kilka "stron" LCD - przez shalvan - 20-09-2015, 11:21
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 11:38
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 12:41
RE: Kilka "stron" LCD - przez shalvan - 20-09-2015, 13:05
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 15:27
RE: Kilka "stron" LCD - przez shalvan - 20-09-2015, 19:46
RE: Kilka "stron" LCD - przez adix - 20-09-2015, 22:52
RE: Kilka "stron" LCD - przez shalvan - 21-09-2015, 06:28
RE: Kilka "stron" LCD - przez adix - 21-09-2015, 17:21
RE: Kilka "stron" LCD - przez shalvan - 26-09-2015, 10:35
RE: Kilka "stron" LCD - przez JasQ - 26-09-2015, 12:39
RE: Kilka "stron" LCD - przez shalvan - 26-09-2015, 13:34
RE: Kilka "stron" LCD - przez JasQ - 26-09-2015, 14:03
RE: Kilka "stron" LCD - przez shalvan - 26-09-2015, 15:19
RE: Kilka "stron" LCD - przez JasQ - 26-09-2015, 15:47
RE: Kilka "stron" LCD - przez shalvan - 26-09-2015, 18:32
RE: Kilka "stron" LCD - przez JasQ - 26-09-2015, 18:56
RE: Kilka "stron" LCD - przez shalvan - 27-09-2015, 12:52
RE: Kilka "stron" LCD - przez JasQ - 27-09-2015, 15:16
RE: Kilka "stron" LCD - przez shalvan - 27-09-2015, 16:42
RE: Kilka "stron" LCD - przez JasQ - 27-09-2015, 22:24

Skocz do:


Przeglądający: 1 gości