#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int jasnosc = 0;
int zmiana = 5;


void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Napiecie:");
  lcd.setCursor(0, 1);
  lcd.print("0.00 V");


}

void loop() {
  // put your main code here, to run repeatedly:


  analogWrite(11, jasnosc);
  jasnosc = jasnosc + zmiana;


  double odczyt = 0;
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Napiecie:");
  lcd.setCursor(0, 1);
  lcd.print("0.00 V");


  odczyt = analogRead(A0) * 5.0 / 1024.0;
  lcd.setCursor(0, 1);
  lcd.print(odczyt);
  lcd.setCursor(12, 1);
  lcd.print(jasnosc);
  delay(500);
  lcd.noDisplay();
  delay(500);
  lcd.display();

  if (jasnosc == 0 || jasnosc == 255) {
    zmiana = 0 - zmiana;}
    delay(30);
  }
