ARDUINO DERS-26 (JOYSTİC ILE 2X16 LCD EKRANA YAZI YAZMA)




DEVRE SEMASI

MALZEMELER

  • 1X ARDUINO
  • 1X 2X16 LCD EKRAN
  • 1X JOYSTİC
  • 1X 10K POTASYOMETRE


DEVRE KODU

#include <LiquidCrystal.h>;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char Buyukveri[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I','J','K','L','M','N','O','P','R','S','T','U','V','Y','Z'};
char veri[] =      {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i','j','k','l','m','n','o','p','r','s','t','u','v','y','z'};
int elemanSayisi = sizeof(veri);
int xPin=A0;
int yPin=A1;
int Sw=8;
int cr=0; int str=0;
int alfabeSira=0;
bool butonDurum=false;

void setup() {
pinMode(xPin,INPUT);
pinMode(yPin,INPUT);
pinMode(Sw,INPUT_PULLUP);
Serial.begin(9600);

  lcd.begin(16, 2);
  lcd.cursor();
  lcd.setCursor(str, cr);
}

void loop() {

  int x=analogRead(xPin);
  int y=analogRead(yPin);
  int S=digitalRead(Sw);


if(S==LOW){
    if(butonDurum==false){butonDurum=true; }else{butonDurum=false;}
    delay(300);
  }


      if(x==1023){
          if(cr==15 && str==1){cr=0; str=0; lcd.setCursor(cr, str);
          }else{
          if(cr==15){str++; cr=0;lcd.setCursor(cr, str);
        }else{
          cr++;  lcd.setCursor(cr, str);}
        }
        alfabeSira=0;
       delay(250);
      }

     
      if(x==0){
       
         if(cr==0 && str==0){cr=15; str=1; lcd.setCursor(cr, str);}
         else if(cr==0 && str==1){str--; cr=15; lcd.setCursor(cr, str);}
         else{cr--; lcd.setCursor(cr, str); }
          alfabeSira=0;
         delay(250);
        }
     

      if(y==0){
          if(butonDurum==false){
                lcd.write(veri[alfabeSira]);
                lcd.setCursor(cr, str);
                alfabeSira++; if(alfabeSira>elemanSayisi){alfabeSira=0; lcd.write(veri[alfabeSira]);  lcd.setCursor(cr, str);   }
                delay(250);         
            }else{
                lcd.write(Buyukveri[alfabeSira]);
                lcd.setCursor(cr, str);
                alfabeSira++; if(alfabeSira>elemanSayisi){alfabeSira=0; lcd.write(Buyukveri[alfabeSira]);  lcd.setCursor(cr, str);   }
                delay(250);
          }
        }

      if(y==1023){
          if(butonDurum==false){
            alfabeSira--;
            if(alfabeSira<0){alfabeSira=sizeof(veri)-1;}
            lcd.write(veri[alfabeSira]);
            lcd.setCursor(cr, str);
            delay(250);
          }else{
            alfabeSira--;
            if(alfabeSira<0){alfabeSira=sizeof(Buyukveri)-1;}
            lcd.write(Buyukveri[alfabeSira]);
            lcd.setCursor(cr, str);
            delay(250);         
          }
         
        }
       
}

Yorumlar

Bu blogdaki popüler yayınlar

ARDUINO DERS-22 (PİYANO YAPIMI)

ARDUINO DERS-28 (5110 LCD İLE YILAN OYUNU)

ARDUINO DERS-10 (HC-SR04 ultrasonik mesafe sensörü )