/*#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int x = 8008135;

void setup() {
  lcd.begin(16, 2);
  
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("Stevec: ");
  lcd.setCursor(10, 1);
  lcd.print(millis()/1000);
  lcd.setCursor(0, 0);
  lcd.print("Primer: ");
  lcd.setCursor(10, 0);
  lcd.print(x);
}
*/




/*#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int counter = 10;
String str_beseda = "Besedilo";
char * beseda = "JANEZ";

void setup() {
  lcd.begin(16, 2);
  
}

void loop() {
  //tekstPrint("BESEDILO!");
  //tekstPrint(str_beseda);
  tekstPrint(beseda);
  //steviloPrint(100);
  steviloPrint(counter);
}

//void tekstPrint(char *tekst) { //*tekst - kazalec/pointer = kaže na prvo črko, gre skozi vse črke
void tekstPrint(String tekst) {
  lcd.setCursor(0, 1); // prvi stolpec druga vrstica
  lcd.print(tekst);
}

void steviloPrint(int x) {
  lcd.setCursor(0, 0);
  lcd.print(x);
}
*/




// Valovanje levo desno ipd.

/*#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
char stev = " ";
String symb = ">";
String symb2 = "<";
int del = 50;

void setup() {
  lcd.begin(16, 2);
  
}

void loop() {
  for (int x = -1; x < 15; x++) {
    if ((x % 2) == 0) {
      lcd.setCursor(x, 1);
      lcd.print(stev);
      lcd.print(symb);
      //delay(del);
      lcd.setCursor(x, 0);
      lcd.print(stev);
      lcd.print(symb);
      delay(del);
    }
    else {
      lcd.setCursor(x, 0);
      lcd.print(stev);
      lcd.print(symb);
      //delay(del);
      lcd.setCursor(x, 1);
      lcd.print(stev);
      lcd.print(symb);
      delay(del);
    }
  }
  for (int x = 15; x > -1; x--) {
    if ((x % 2) == 0) {
      lcd.setCursor(x, 1);
      lcd.print(symb2);
      lcd.print(stev);

      //delay(del);

      lcd.setCursor(x, 0);
      lcd.print(symb2);
      lcd.print(stev);

      delay(del);
    }
    else {
      lcd.setCursor(x, 0);
      lcd.print(symb2);
      lcd.print(stev);

      //delay(del);

      lcd.setCursor(x, 1);
      lcd.print(symb2);
      lcd.print(stev);
      delay(del);

    }
  }
}*/




// 3. vaja: Izpis svojega znaka

/*#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

byte hertz[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};

byte noHertz[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b01110,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};

void setup() {
  lcd.begin(16, 2);
  lcd.createChar(1, hertz); // če ga izpisujem, ga kličem z številko 1
  lcd.createChar(2, noHertz);
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.write(1);
  lcd.write(2);
}*/




// vaja 4: izpis seznama tipa string

/*#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

int del = 300;
char ch_imena[3][11] = {
  "Janez",
  "Minka",
  "Alenka"
};
String ch_imena1[3] = {
  "Janez",
  "Minka",
  "Alenka"
};

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  for (int x = 0; x < 3; x++) {
    lcd.clear();
    String n = ch_imena1[x];
    char *m = ch_imena[x];
    tekstPrint(m, x);
    delay(del);
  }
}

void tekstPrint(char *tekst, int y) {
  lcd.setCursor(0, 0);
  lcd.print(tekst);
  lcd.setCursor(0, 1);
  lcd.print(y);
}

void tekstPrint2(String tekst, int y) {
  lcd.setCursor(0, 0);
  lcd.print(tekst);
  lcd.setCursor(0, 1);
  lcd.print(y);
}*/




//Vaja 4: LED prikaz potenciometra
//Prikaz spremenljivke, ki jo poveča pritisk gumba za 1


#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

int del = 100;
int vrednost = 0;


void setup() {
  lcd.begin(16, 2);
  DDRD &= 0b11101111;
  PORTD = 0x10;
  ADMUX = (1 << REFS0);
  ADCSRA = (0 << ADPS2) | (0 << ADPS1) | (1 << ADPS0);
  ADCSRA = (1 << ADEN);
}

void loop() {
  ADCSRA |= (1 << ADSC);
  while (ADCSRA & (1 << ADSC)) {

  };
  int pot = ADC;
  int gumb = PIND & 0x10;
  if (gumb != 16){
    vrednost ++;
  }
  delay(del);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(vrednost);
  lcd.setCursor(0, 1);
  lcd.print(pot);
  
}