27-09-2015, 15:16
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
Arduino UNO, TINY, PRO MINI
Pomoc nagradzamy punktami reputacji