#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <menu.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define BUTTONS_PIN A3
#define CLKP A2
#define DT A1
int butdeger;
int counterBE = 0;
int currentStateCLK;
int lastStateCLK;
String currentDir = "";
unsigned int timeOn=10;
unsigned int timeOff=90;
#define MAX_DEPTH 2
MENU(mainMenu, "Blink menu", Menu::doNothing, Menu::noEvent, Menu::wrapStyle
,FIELD(timeOn,"On","ms",0,1000,10,1, Menu::doNothing, Menu::noEvent, Menu::noStyle)
,FIELD(timeOff,"Off","ms",0,10000,10,1,Menu::doNothing, Menu::noEvent, Menu::noStyle)
,EXIT("<Back")
);
MENU_OUTPUTS(out, MAX_DEPTH
,LCD_OUT(lcd,{0,0,20,4})
,NONE
);
NAVROOT(nav, mainMenu, MAX_DEPTH, in, out);
void setup() {
// put your setup code here, to run once:
pinMode (BUTTONS_PIN, INPUT);
pinMode (CLKP, INPUT);
pinMode (DT, INPUT);
lcd.init(); // LCD ekranını başlatın
lcd.backlight(); // Arkadan aydınlatmayı etkinleştirin
lcd.clear();
lcd.begin(20,4);
}
void loop() {
// put your main code here, to run repeatedly:
nav.poll();
currentStateCLK = digitalRead(CLKP); // Read the current state of CLK
if (currentStateCLK != lastStateCLK && currentStateCLK == 1)
{
if (digitalRead(DT) != currentStateCLK)
{
counterBE --;
currentDir = "CCW";
} else
{
counterBE ++;
currentDir = "CW";
}
}
lastStateCLK = currentStateCLK;
/*
butdeger = analogRead(BUTTONS_PIN);
if (butdeger == 0)
{
lcd.setCursor(0,0);
lcd.print("YESIL BUTONA BASILDI");
}
else if (butdeger != 0)
{
lcd.clear();
}
*/
}