#define SET0(REG,BIT) REG &= ~(1<<BIT)
#define SET1(REG,BIT) REG |= (1<<BIT)
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27 ,16, 2);
void setup() {
SET0 (DDRD,2);
lcd.init();
lcd.backlight();
SET0(ADMUX,REFS1); // voľba Aref
SET0(ADMUX,REFS0);
SET1(ADMUX,ADLAR); // zarovnanie nahor
SET1(ADMUX,MUX0); // voľba kanála ADC1
SET0(ADMUX,MUX1);
SET0(ADMUX,MUX2);
SET0(ADMUX,MUX3);
SET1(ADIE,SREG);
SET1(ADCSRA,ADATE); // spúšťanie príkazom
SET0(ADCSRA,ADIE); // negenerovanie prerušenia
SET1(ADCSRA,ADPS2); // voľba preddeličky 128
SET1(ADCSRA,ADPS1);
SET1(ADCSRA,ADPS0);
SET1(ADCSRA,ADEN); // zapnutie ADC
}
void loop() {
lcd.println(ADCH);
}