// นำ file menu-timecontrol รวมกับ pj-timecontrol-button-uno2
// Run ผ่านแล้ว ฝากไว้ก่อน lcd.cursor(); lcd.noBlink(); lcd.noCursor();
#include <Wire.h>
#include "RTClib.h" // การประกาศหลัง #include ใช้ได้ทั้ง <...> / "..."
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // ค่า 0x27 เป็นค่าเฉพาะแต่ละบอร์ด จอ
RTC_DS1307 RTC; // ประกาศใช้ RTC สำหรับ นาฬิกา DS1307
//************Button*****************//
int St=A2; // Button SET MENU' PB0
int UP=A1; // Button + Yellow PB1
int Down=A0; // Button - Green PB5
int OK=2; // togle Alarm on or off
int btt;
int Run;
//int StAl=13; // set Alarm PB3
#define LED1 3 //
/**************Alarm***************
#define LED2 A1 //PC1
#define LED3 A2 //PC2
#define LED4 A3 //PC3
#define buzzer 10 //PB2
//************Variables*************
*/
int x=0;
int minupg;
int menu =0;
//int setAll =0;
byte a=0,b=0,c,d,aa,bb,cc,dd;
//int *x;
void setup()
{
lcd.begin(20,4);
lcd.setBacklight(255);
//lcd.clear();
Wire.begin();
RTC.begin();
Serial.begin(9600);
pinMode(St,INPUT_PULLUP); // https://www.arduino.cc/en/Tutorial/InputPullupSerial
pinMode(UP,INPUT_PULLUP);
pinMode(Down,INPUT_PULLUP);
pinMode(OK,INPUT_PULLUP);
pinMode(LED1,OUTPUT);
}
void loop()
{
lcd.setCursor(0, 0);
lcd.print("Main1 loop1");
lcd.setCursor(0, 2);
lcd.print(a);
lcd.print(" ");
lcd.print(b);
delay(2500);
active(a,b,c,d,&aa,&bb,&cc,&dd);//send variable and Address
a=aa;
b=bb;
c=cc;
d=dd;
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("aa=");
lcd.print(aa);
lcd.print(" bb=");
lcd.print(bb);
lcd.print("cc=");
lcd.print(cc);
lcd.print("dd=");
lcd.print(dd);
delay(2500);
}
byte active(byte a,byte b,byte c,byte d,byte*aa,byte*bb,byte*cc,byte*dd)
{
*aa=a+1;
*bb=b+2;
*cc=b+3;
*dd=b+4;
//aa=*aa;
//bb=*bb;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Loop2");
lcd.print("aa=");
a=aa-0;
lcd.print(a); // ใน loop oี้ print ไม่ได้ งง
lcd.print(" bb=");
b=bb-0;
lcd.print(b);
delay(2500);
return dd;
}