Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2021.07.10. v.1.0
- // Gépekhez időzítő, 9 csatorna
- // 2*16-os LCD kijelzővel
- // 7 szegmenses kijelző, nano, encoder
- // 1 másodperces tikkeléssel, óra, perc, másodperc beállítási lehetőséggel, érték mentve.
- // Alap helyzetben csak a kijelzőn látszik az utoljára megnézett vagy beállított hátralévő idő
- // Encoder állításával a timerek között lehet lépkedni, melynek van Active és nem aktív állása
- // 2 gomb van.
- // 1. Encoder gombja, Start - a kijelzőn aktuálisan látható timer indul
- // 2. Reset - A riasztás törlése
- // A nagy, 1 digites kijelzőn az éppen aktuális timer száma jelenik meg, kivéve, ha riasztás van.
- // Ha 10 sec-ig nincs változás, akkor automatikusan eltűnik. dispOff=10
- // Riasztás esetén a lejárt időzítő száma látható, valamint hangjelzés is hallható, mindig az utolsónak a szignálja.
- // A risztást nyugtázni kell, addig lesz, amíg nincs megnyova a reset gomb.
- // Ha valamilyen beállításban lesz riasztás, akkor NEM menti az aktuális értéket és kilép a beállításból. A beállításba újból be kell lépni, nem lép vissza automatikusan a riasztás után.
- // Kezel 2 db 10 gombos távirányítót. A gombok 1-9-ig a timerek indítására szolgálnak, míg a 10. gomb riasztás esetén törli az aktuális riasztást.
- // EEPROM memory map
- // 02-20 Timers starting time
- // 22 - Volume
- // 23 - Brightness
- // 24 - Language (1-English, 2-Deutsch, - 3-France, 4-Spain, 5-Hungary)
- // 25 - Maximum number of alarm MP3s (in folder 99)
- // 31-39 - Number of MP3 files assigned to the timers (in folder 99)
- // 40-120 - Remote control data
- // 130-150 - Number of timer alarms, not yet included!
- #include <EEPROM.h>
- #include <LiquidCrystal_I2C.h>
- #include <Rotary.h>
- #include "SoftwareSerial.h"
- #include "DFRobotDFPlayerMini.h"
- #include "customchar.h"
- #include <RCSwitch.h>
- // TPIC6C596 shift register
- #define DOUT 4
- #define CLK 6
- #define NLE 7
- #define BR 5
- #define encButton A0
- #define Button A3
- #define CHKDISP 3
- unsigned long lastDebounceTime = 0,lastDebounceTime1 = 0;
- unsigned long debounceDelay = 50;
- unsigned long longPressDelay = 1000;
- unsigned long buttonCounter,buttonCounter1;
- unsigned long currentMillis;
- unsigned long previousMillis;
- bool readingButton,readingButton1;
- bool buttonShort=false,buttonShort1=false;
- bool buttonLong=false,buttonLong1=false;
- bool buttonShortPress=false,buttonShortPress1=false;
- bool buttonLongPress=false,buttonLongPress1=false;
- bool reading,reading1;
- unsigned long remoteData[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; // Remote control codes, 2 * 10 buttons
- unsigned long val=0;
- // 0 1 2 3 4 5 6 7 8 9 _ - H E L
- const byte kari[] ={123, 65,179,227,201,234,250, 67,251,235,0,128,217,186, 56};
- unsigned int timerKezd[]={100,600,600,600,600,600,600,600,600,600}; // Initial value of timers
- unsigned int timer[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // The current value of the timers
- byte timerMP3[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // The serial number of the MP3 for the timers
- bool riaszt[] = {0,0,0,0,0,0,0,0,0,0}; // Do the timers alarm
- bool voice=true; // In the event of an alarm, speak or music, speak first
- byte timerNum=1; // The number of the current timer
- byte alarmNum=0; // The number of the current alarm, which timer is alarming, 0 - none
- byte ora, perc, sec;
- byte dispOff=10; // Turn off the large display
- // 0 1 2 3 4 5 6 7 8 9 10 11
- const byte brightness[]={255,249,240,229,217,204,189,170,148,119,79,10};
- byte actualBrightness;
- byte actualVolume;
- byte maxMP3=38; // the MP3s are in folder 99.
- byte actualMP3=0, counterMP3=0;
- byte type;
- bool setting=false;
- bool settingVolume=false;
- bool settingBrightness=false;
- bool setActual=false; // Set the current time
- bool setVol=false; // When setting the timer time, add the MP3 associated with the current timer
- //unsigned int counter=0;
- byte counter=0;
- byte lang=0; // A nyelv száma (1-5)
- float tmp=0;
- long value; // RCSwitch
- unsigned char result;
- LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
- Rotary r = Rotary(A2, A1); // define rottary encoder and pins
- SoftwareSerial mySoftwareSerial(9, 8); // RX, TX
- RCSwitch mySwitch = RCSwitch();
- DFRobotDFPlayerMini myDFPlayer;
- void setup() {
- lcd.init(); // initialize the lcd
- lcd.backlight();
- r.begin(true);
- pinMode(DOUT, OUTPUT);
- pinMode(CLK, OUTPUT);
- pinMode(NLE, OUTPUT);
- pinMode(encButton, INPUT_PULLUP);
- pinMode(Button, INPUT_PULLUP);
- pinMode(CHKDISP, INPUT_PULLUP);
- digitalWrite(NLE, HIGH);
- digitalWrite(CLK, LOW);
- digitalWrite(DOUT, LOW);
- analogWrite(BR, 220);
- mySoftwareSerial.begin(9600);
- mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
- Serial.begin(115200);
- Serial.println("Start ...");
- for (byte j=6;j>0;j--){
- for (byte i=0;i<8;i++){
- s0[i]=32-pow(2,j-1);
- }
- lcd.createChar(6-j, s0);
- }
- shift(0); //clear
- lcd.clear();
- if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
- lcd.print(" Please insert");
- lcd.setCursor(0,1);
- lcd.print(" the SD card!");
- //while(true);
- delay(5000);
- lcd.clear();
- }
- if (digitalRead(CHKDISP)==HIGH) { //
- lcd.print("No 7 seq. displ.");
- lcd.setCursor(0,1);
- lcd.print(" Need connect");
- //while(true);
- delay(5000);
- lcd.clear();
- }
- //ment(); // Set the first time
- for (byte i=1;i<10;i++){
- EEPROM.get(i*2, timerKezd[i]);
- timerMP3[i]=EEPROM.read(i+30);
- }
- for (byte i=0;i<20;i++){
- EEPROM.get(40+i*4, remoteData[i]);
- Serial.print(i);
- Serial.print(" ");
- Serial.print(40+i*4);
- Serial.print(" ");
- Serial.println(remoteData[i]);
- }
- // EEPROM.write(22,10); // Set the first time
- // EEPROM.write(23,3);
- actualVolume=EEPROM.read(22);
- actualBrightness=EEPROM.read(23);
- lang=EEPROM.read(24);
- maxMP3=EEPROM.read(25);
- if (lang==255) lang=1; // If the value is too large (empty EEPROM), it will be the default value, English
- myDFPlayer.volume(actualVolume); //Set volume value. From 0 to 30
- myDFPlayer.playFolder(lang, 1); // Welcome voice
- analogWrite(BR, brightness[actualBrightness]);
- lcd.setCursor(0,0);
- langWorld(1);
- lcd.print(actualBrightness);
- lcd.setCursor(0,1);
- langWorld(2);
- lcd.print(actualVolume);
- delay(1000);
- lcd.clear();
- lcd.setCursor(2,0);
- langWorld(3);
- lcd.print(lang);
- lcd.setCursor(2,1);
- lcd.print(" MP3: ");
- lcd.print(maxMP3);
- delay(1000);
- counter=0;
- if (digitalRead(encButton)==LOW) counter++;
- if (digitalRead(Button)==LOW) counter=counter+2;
- Serial.println("Counter: ");
- Serial.println(counter);
- if (counter==3) {
- Serial.println("Remote SET");
- kiir3();
- while(!digitalRead(Button));
- Serial.println("Remote SET start");
- remoteSet();
- counter=0;
- }
- if (counter==2) {
- Serial.println("Lang SET");
- lcd.clear();
- lcd.setCursor(2,0);
- langWorld(3);
- lcd.print(lang);
- lcd.setCursor(2,1);
- langWorld(4);
- while(!digitalRead(Button));
- Serial.println("Lang SET start");
- langSet();
- EEPROM.write(24,lang);
- counter=0;
- }
- if (counter==1) {
- Serial.println("Alarm MP3 numset");
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Maximum number");
- lcd.setCursor(0,1);
- lcd.print("of MP3s: ");
- lcd.setCursor(10,1);
- lcd.print(maxMP3);
- while(!digitalRead(encButton));
- Serial.println("Alarm MP3 numset start");
- MP3Set();
- if (maxMP3==0){
- statRead();
- } else {
- EEPROM.write(25,maxMP3);
- }
- delay(2000);
- }
- lcd.clear();
- kiir();
- }
- void statRead(){
- unsigned int count;
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Statistics");
- delay(1000);
- //while(!digitalRead(Button)); // waiting for up button
- counter=0;
- while(digitalRead(encButton)){
- result = r.process();
- if (result==DIR_CCW and counter<10) {
- counter++;
- lcd.setCursor(10,1);
- lcd.print(counter);
- lcd.print(" ");
- Serial.print(counter);
- Serial.print(" ");
- Serial.println(128+counter*2);
- }
- if (result==DIR_CW and counter>1) {
- counter--;
- lcd.setCursor(10,1);
- lcd.print(counter);
- lcd.print(" ");
- Serial.print(counter);
- Serial.print(" ");
- Serial.println(128+counter*2);
- }
- }
- }
- void MP3Set(){
- delay(1000);
- while(!digitalRead(Button)); // waiting for up button
- counter=0;
- while(digitalRead(encButton)){
- result = r.process();
- if (result==DIR_CCW and maxMP3<250) {
- maxMP3++;
- lcd.setCursor(10,1);
- lcd.print(maxMP3);
- lcd.print(" ");
- }
- if (result==DIR_CW and maxMP3>1) {
- maxMP3--;
- lcd.setCursor(10,1);
- lcd.print(maxMP3);
- lcd.print(" ");
- }
- }
- }
- void loop() {
- currentMillis = millis();
- if (currentMillis - previousMillis >= 1000) { // Timer every 1 second due to display refresh
- previousMillis = currentMillis;
- tick();
- }
- pressButton();
- pressButton1();
- result = r.process();
- if (settingVolume==false) { // Secondary adjustment function, volume and brightness adjustment
- if (setting==false) { // normal mode
- if (buttonLong==true){ // Long press on the encoder button, enter the time setting menu
- reading=false;
- buttonLong=false;
- Serial.println("Long Press Normal"); // The button has been pressed long time
- if (riaszt[timerNum]==0) setting=true; // Switches to setting only when there is no alarm
- setActual=false;
- }
- if (buttonShort==true and readingButton==HIGH){ // Short press of encoder button, current timer START
- reading=false;
- buttonShort=false;
- Serial.println("Short Press Normal"); // The button has been pressed short time
- if (alarmNum == 0) {
- shift(kari[timerNum]);
- dispOff=10;
- timer[timerNum]=timerKezd[timerNum];
- myDFPlayer.playFolder(lang, 1+timerNum);
- }
- }
- if (buttonLong1==true){ // long press reset button
- reading1=false;
- buttonLong1=false;
- Serial.println("Long Press 1 Normal"); // The button has been pressed long time
- settingVolume=true;
- settingBrightness=false; // It starts with a volume setting
- myDFPlayer.playFolder(99, 11); // The number of the randomly selected audio file for the volume setting is 11
- kiir1();
- }
- if (buttonShort1==true and readingButton1==HIGH){ // short press reset button, clear alarm
- reading1=false;
- buttonShort1=false;
- Serial.println("Short Press 1 Normal"); // The button has been pressed short time
- riaszt[alarmNum]=false;
- voice=true;
- myDFPlayer.pause(); //Stop the mp3
- alarmNum=0;
- dispOff=5;
- }
- if (result == DIR_CCW and alarmNum==0) { // If there is no active alarm, you can switch between timers
- timerNum++;
- if (timerNum==10) timerNum=9;
- if (timer[timerNum]!=0) {
- shift(kari[timerNum]);
- dispOff=5;
- } else {
- shift(0);
- }
- kiir();
- }
- if (result == DIR_CW and alarmNum==0) { // If there is no active alarm, you can switch between timers
- timerNum--;
- if (timerNum==0) timerNum=1;
- if (timer[timerNum]!=0) {
- shift(kari[timerNum]);
- dispOff=5;
- } else {
- shift(0);
- }
- kiir();
- }
- } else { // setting=true
- if (buttonLong==true){
- reading=false;
- buttonLong=false;
- Serial.println("Long Press Setting"); // The button has been pressed long time
- setting=false;
- ment();
- }
- if (buttonShort==true and readingButton==HIGH){
- reading=false;
- buttonShort=false;
- Serial.println("Short Press Setting"); // The button has been pressed short time
- if (timer[timerNum]!=0) { // The current timer can only be set to active if it is not zero
- if (setActual==false) {
- setActual=true;
- kiir();
- } else {
- setActual=false;
- kiir();
- }
- }
- }
- if (buttonLong1==true){ // long press reset button, exit the setting
- reading1=false;
- buttonLong1=false;
- Serial.println("Long Press 1 Setting"); // The button has been pressed long time
- if (setVol==false){ // Switch between timer time and associated MP3 setting
- setVol=true;
- actualMP3=timerMP3[timerNum]; // The MP3 number of the current timer
- counterMP3=actualMP3;
- kiir2();
- } else {
- setVol=false;
- myDFPlayer.pause(); // Stop mp3
- kiir();
- }
- }
- if (buttonShort1==true and readingButton1==HIGH){ // reset button short press, MP3 setting
- reading1=false;
- buttonShort1=false;
- Serial.println("Short Press 1 Setting"); // The button has been pressed short time
- actualMP3=counterMP3;
- timerMP3[timerNum]=counterMP3; // Enter the current timer MP3
- kiir2();
- }
- if (result == DIR_CCW and setVol==false) { // timer time setting if the MP3 track number setting is not
- if (setActual==false) {
- timerKezd[timerNum]+=60;
- if (timerKezd[timerNum]>65000) timerKezd[timerNum]=65000;
- kiir();
- } else {
- timer[timerNum]+=60;
- if (timer[timerNum]>65000) timer[timerNum]=65000;
- kiir();
- }
- }
- if (result == DIR_CW and setVol==false) { // timer time setting if the MP3 track number setting is not
- if (setActual==false) {
- timerKezd[timerNum]-=60;
- if (timerKezd[timerNum]>65000 or timerKezd[timerNum]<60) timerKezd[timerNum]=60;
- kiir();
- } else {
- timer[timerNum]-=60;
- if (timer[timerNum]>65000 or timer[timerNum]<60) timer[timerNum]=60;
- kiir();
- }
- } // end DIR_CW
- if (result == DIR_CCW and setVol==true and counterMP3<maxMP3) { // Set the MP3 sequence number if the counter is less than the max.
- counterMP3++;
- myDFPlayer.playFolder(99, counterMP3);
- delay(200);
- kiir2();
- }
- if (result == DIR_CW and setVol==true and counterMP3>0) { // Set the MP3 track number if greater than 0
- counterMP3--;
- myDFPlayer.playFolder(99, counterMP3);
- delay(200);
- kiir2();
- } // end DIR_CW
- } // END setting
- } else { // Setting volume or Brigthness, settingVolume=true
- if (buttonLong1==true){ // long press reset button, exit the setting
- reading1=false;
- buttonLong1=false;
- Serial.println("Long Press 1 Volume/Brightness setting"); // The button has been pressed long time
- settingVolume=false;
- myDFPlayer.pause(); // Stop mp3
- shift(0);
- kiir();
- EEPROM.write(22,actualVolume);
- EEPROM.write(23,actualBrightness);
- }
- if (buttonShort1==true and readingButton1==HIGH){ // reset button short press, switch between settings: volume / brightness
- reading1=false;
- buttonShort1=false;
- Serial.println("Short Press 1 Volume/Brightness setting"); // The button has been pressed short time
- if (settingBrightness==false) {
- settingBrightness=true;
- myDFPlayer.pause(); // Stop mp3
- shift(kari[8]);
- kiir1();
- } else {
- settingBrightness=false;
- //myDFPlayer.play(11); // Test mp3
- myDFPlayer.playFolder(99, 11);
- shift(0);
- kiir1();
- }
- }
- if (settingBrightness==false) { // Volume setting
- if (result == DIR_CCW and alarmNum==0) { // If there is no active alarm, the value can be changed
- actualVolume++;
- if (actualVolume==31) actualVolume=30;
- myDFPlayer.volume(actualVolume); //Set volume value. From 0 to 30
- kiir1();
- }
- if (result == DIR_CW and alarmNum==0) { // If there is no active alarm, the value can be changed
- actualVolume--;
- if (actualVolume==0) actualVolume=1;
- myDFPlayer.volume(actualVolume); //Set volume value. From 0 to 30
- kiir1();
- }
- } else { // Brightness setting
- if (result == DIR_CCW and alarmNum==0) { // If there is no active alarm, the value can be changed
- actualBrightness++;
- if (actualBrightness==11) actualBrightness=10;
- analogWrite(BR, brightness[actualBrightness]);
- kiir1();
- }
- if (result == DIR_CW and alarmNum==0) { // If there is no active alarm, the value can be changed
- actualBrightness--;
- if (actualBrightness==0) actualBrightness=1;
- analogWrite(BR, brightness[actualBrightness]);
- kiir1();
- }
- }
- }
- value=0;
- chkRemote();
- if (value!=0){
- counter=99;
- for (byte i=0;i<20;i++){
- if (value==remoteData[i]) {
- counter=i;
- }
- }
- if (counter==9 or counter==19) { // Unless button 10 on any remote control
- riaszt[alarmNum]=false;
- voice=true;
- myDFPlayer.pause(); //Stop the mp3
- alarmNum=0;
- dispOff=5;
- } else {
- if (counter!=99) { // Press 1-9 on the remote control
- if (alarmNum==0) { // No alarm, timer can be started
- timerNum=(counter-(counter/10)*10+1);
- shift(kari[timerNum]);
- dispOff=10;
- timer[timerNum]=timerKezd[timerNum];
- myDFPlayer.playFolder(lang, 1+timerNum);
- }
- }
- }
- }
- chkMP3();
- } // END LOOP
- void chkMP3(){
- if (myDFPlayer.available()) { // Query MP3 player
- type=myDFPlayer.readType();
- Serial.print(type);
- Serial.print(" DFPlayer ");
- Serial.println(myDFPlayer.read());
- if (type==6) { // There is no such number of MP3s
- Serial.println("There is no such number of MP3s");
- }
- if (alarmNum!=0){
- if (voice==false) { // speech or music test
- myDFPlayer.playFolder(lang, 10+alarmNum);
- voice=true;
- } else {
- myDFPlayer.playFolder(99, timerMP3[alarmNum]);
- voice=false;
- }
- }
- }
- }
- void kiir1() { // for secondary setting
- lcd.clear();
- if (settingBrightness==false) {
- lcd.setCursor(0,0);
- langWorld(2); // Volume
- lcd.print(actualVolume);
- lcd.setCursor(0,1);
- tmp=actualVolume;
- tmp=tmp*2.67;
- byte a1=tmp/5;
- byte a2=tmp-a1*5;
- for (byte i=0;i<a1;i++){
- lcd.write(5);
- }
- lcd.write(a2);
- } else {
- lcd.setCursor(0,0);
- langWorld(1); // Brightness
- lcd.print(actualBrightness);
- lcd.setCursor(0,1);
- tmp=actualBrightness;
- tmp=tmp*8;
- byte a1=tmp/5;
- byte a2=tmp-a1*5;
- for (byte i=0;i<a1;i++){
- lcd.write(5);
- }
- lcd.write(a2);
- }
- }
- void kiir2() {
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Timer: ");
- lcd.print(timerNum);
- lcd.setCursor(10,0);
- if (counterMP3<10) lcd.print(" ");
- lcd.print(counterMP3);
- lcd.setCursor(0,1);
- lcd.print("Actual MP3: ");
- if (actualMP3<10) lcd.print(" ");
- lcd.print(actualMP3);
- }
- void kiir3(){
- lcd.clear();
- lcd.print(" Remote control");
- lcd.setCursor(0,1);
- lcd.print(counter/10+1);
- lcd.print("-");
- lcd.print(counter-(counter/10)*10+1);
- lcd.print(" ");
- lcd.print(remoteData[counter]);
- }
- void kiir() {
- if (setting==false) {
- lcd.setCursor(0,0);
- lcd.print("Timer: ");
- lcd.print(timerNum);
- lcd.setCursor(8,0);
- if (timer[timerNum]!=0) { // Whether current timer is active
- lcd.print(" Active");
- } else {
- if (riaszt[timerNum]==true) {
- lcd.print(" ALARM ");
- } else {
- lcd.print(" ------");
- }
- }
- } else {
- if (setActual==false) {
- lcd.setCursor(0,0);
- lcd.print("Timer: ");
- lcd.print(timerNum);
- lcd.setCursor(8,0);
- lcd.print(" Setting");
- } else {
- lcd.setCursor(0,0);
- lcd.print("Setting ");
- lcd.setCursor(8,0);
- lcd.print("Timer: ");
- lcd.print(timerNum);
- }
- }
- lcd.setCursor(0,1);
- convert(timer[timerNum]); // seconds -> hour, minute, second format
- lcd.print(ora);
- lcd.print(":");
- if (perc<10) lcd.print("0");
- lcd.print(perc);
- lcd.print(":");
- if (sec<10) lcd.print("0");
- lcd.print(sec);
- lcd.print(" ");
- convert(timerKezd[timerNum]); // seconds -> hour, minute, second format
- lcd.print(ora);
- lcd.print(":");
- if (perc<10) lcd.print("0");
- lcd.print(perc);
- // lcd.print(":");
- // if (sec<10) lcd.print("0");
- // lcd.print(sec);
- }
- void convert(unsigned int ido) { // seconds -> hour, minute, second format
- ora=ido/3600;
- ido=ido-ora*3600;
- perc=ido/60;
- sec=ido-perc*60;
- }
- void tick() { // Counter per second
- if (dispOff!=0) {
- dispOff--;
- if (dispOff==0) shift(0);
- }
- for (byte i=1;i<10;i++){ // We take the timers in a row and if they are not zero, we reduce their value
- if (timer[i]!=0) {
- timer[i]--;
- if (timer[i]==0) { // Time has elapsed, alarm indicator setting
- riaszt[i]=true;
- setting=false; // clear setting
- settingVolume=false; // delete secondary setting
- kiir();
- }
- }
- }
- if (alarmNum==0) { // No active alarm, check for background
- for (byte i=1;i<10;i++){ // We take the timers in order
- if (riaszt[i]==true) {
- alarmNum=i;
- timerNum=i;
- shift(kari[timerNum]);
- dispOff=0;
- setting=false; // clear setting
- settingVolume=false; // delete secondary setting
- kiir();
- myDFPlayer.playFolder(lang, 10+alarmNum);
- Serial.print("lang: ");
- Serial.print(lang);
- Serial.print(" 10+alamrmNum ");
- Serial.print(10+alarmNum);
- Serial.print(" PLAY2 (alarmNum): ");
- Serial.println(alarmNum);
- }
- }
- }
- if (settingVolume==false and setVol==false) kiir(); // Volume or Brightness uses another ejection
- } // end tick
- void shift(byte v){
- shiftOut(DOUT, CLK, LSBFIRST, v);
- delay(1);
- digitalWrite(NLE, LOW);
- delay(1);
- digitalWrite(NLE, HIGH);
- }
- void pressButton() {
- readingButton = digitalRead(encButton);
- if (readingButton==LOW and reading==true) {
- buttonCounter++;
- if ((millis() - lastDebounceTime) > debounceDelay) { // Is the prell time out?
- buttonShort=true;
- }
- if ((millis() - lastDebounceTime) > longPressDelay) {
- buttonLong=true;
- buttonShort=false;
- }
- }
- if (readingButton==HIGH) {
- lastDebounceTime=millis();
- buttonCounter=0;
- reading=true;
- }
- }
- void pressButton1() {
- readingButton1 = digitalRead(Button);
- if (readingButton1==LOW and reading1==true) {
- buttonCounter1++;
- if ((millis() - lastDebounceTime1) > debounceDelay) {
- buttonShort1=true;
- }
- if ((millis() - lastDebounceTime1) > longPressDelay) {
- buttonLong1=true;
- buttonShort1=false;
- }
- }
- if (readingButton1==HIGH) {
- lastDebounceTime1=millis();
- buttonCounter1=0;
- reading1=true;
- }
- }
- void ment() {
- Serial.println("mentés");
- for (byte i=1;i<10;i++){
- EEPROM.put(i*2, timerKezd[i]);
- EEPROM.write(i+30,timerMP3[i]); // The MP3 file number assigned to the timers
- }
- }
- void langWorld(byte num){
- if (num==1){
- if (lang==1) lcd.print("Brightness: ");
- if (lang==2) lcd.print("Helligkeit: ");
- if (lang==3) lcd.print("Luminosite: ");
- if (lang==4) lcd.print("Brillo: ");
- if (lang==5) lcd.print("Fenyero: ");
- }
- if (num==2){
- if (lang==1) lcd.print("Volume: ");
- if (lang==2) lcd.print("Volumen: ");
- if (lang==3) lcd.print("Le volume: ");
- if (lang==4) lcd.print("Volume: ");
- if (lang==5) lcd.print("Hangero: ");
- }
- if (num==3){
- if (lang==1) lcd.print("Language: ");
- if (lang==2) lcd.print("Sprache: ");
- if (lang==3) lcd.print("Langue: ");
- if (lang==4) lcd.print("Idioma: ");
- if (lang==5) lcd.print("Nyelv: ");
- }
- if (num==4){
- if (lang==1) lcd.print("English");
- if (lang==2) lcd.print("Deutsche");
- if (lang==3) lcd.print("Francais");
- if (lang==4) lcd.print("Espanol");
- if (lang==5) lcd.print("Magyar");
- }
- }
- void langSet(){
- while(digitalRead(encButton)){
- result = r.process();
- if (result==DIR_CCW and lang<5) {
- lang++;
- lcd.clear();
- lcd.setCursor(2,0);
- langWorld(3);
- lcd.print(lang);
- lcd.setCursor(2,1);
- langWorld(4);
- }
- if (result==DIR_CW and lang>1) {
- lang--;
- lcd.clear();
- lcd.setCursor(2,0);
- langWorld(3);
- lcd.print(lang);
- lcd.setCursor(2,1);
- langWorld(4);
- }
- }
- }
- void chkRemote(){
- if (mySwitch.available()) {
- value=mySwitch.getReceivedValue();
- Serial.print("Received ");
- //Serial.print( mySwitch.getReceivedValue() );
- Serial.print(value);
- Serial.print(" / ");
- Serial.print( mySwitch.getReceivedBitlength() );
- Serial.print("bit. Delay:");
- Serial.print( mySwitch.getReceivedDelay() );
- Serial.print(" Protocol: ");
- Serial.print( mySwitch.getReceivedProtocol() );
- Serial.print(" Byte: ");
- Serial.print(value & 0xFF);
- Serial.print(" - ");
- Serial.print((value >> 8) & 0xFF);
- Serial.print(" - ");
- Serial.print((value >> 16) & 0xFF);
- Serial.print(" - ");
- Serial.println((value >> 24) & 0xFF);
- mySwitch.resetAvailable();
- }
- }
- void remoteSet(){
- delay(1000);
- while(!digitalRead(Button)); // waiting for the button to be released
- counter=0;
- while(digitalRead(Button)){
- value==0;
- chkRemote();
- if (value!=0){
- remoteData[counter]=value;
- value=0;
- kiir3();
- }
- result = r.process();
- if (result==DIR_CCW and counter<19) {
- counter++;
- kiir3();
- }
- if (result==DIR_CW and counter>0) {
- counter--;
- kiir3();
- }
- }
- for (byte i=0;i<20;i++){
- EEPROM.put(40+i*4, remoteData[i]);
- }
- }
- // end program code
- // Languages:
- // 1. English
- // 2. German
- // 3. French
- // 4. Spanish
- // 5. Hungarian
- //
- // 1. English speaking
- // 01. Welcome! Good luck using the nine channel timer.
- // 02. The first timer started.
- // 03. The second timer started.
- // 04. The third timer started.
- // 05. The fourth timer has started.
- // 06. The fifth timer has started.
- // 07. The sixth timer has started.
- // 08. The seventh timer has started.
- // 09. The eighth timer has started.
- // 10. The ninth timer has started.
- // 11. The first timer has expired.
- // 12. The second timer has expired.
- // 13. The third timer has expired.
- // 14. The fourth timer has expired.
- // 15. The fifth timer has expired.
- // 16. The sixth timer has expired.
- // 17. The seventh timer has expired.
- // 18. The eighth timer has expired.
- // 19. The ninth timer has expired.
- //
- // 2. German speaking
- // 01. Herzlich willkommen! Viel Glück mit dem 9-Kanal-Timer.
- // 02. Der erste Timer ist gestartet.
- // 03. Der zweite Timer ist gestartet.
- // 04. Der dritte Timer ist gestartet.
- // 05. Der vierte Timer ist gestartet.
- // 06. Der fünfte Timer ist gestartet.
- // 07. Der sechste Timer ist gestartet.
- // 08. Der siebte Timer ist gestartet.
- // 09. Der achte Timer ist gestartet.
- // 10. Der neunte Timer ist gestartet.
- // 11. Der erste Timer ist abgelaufen.
- // 12. Der zweite Timer ist abgelaufen.
- // 13. Der dritte Timer ist abgelaufen.
- // 14. Der vierte Timer ist abgelaufen.
- // 15. Der fünfte Timer ist abgelaufen.
- // 16. Der sechste Timer ist abgelaufen.
- // 17. Der siebte Timer ist abgelaufen.
- // 18. Der achte Timer ist abgelaufen.
- // 19. Der neunte Timer ist abgelaufen.
- //
- // 3. French speaking
- // 01. Bienvenue! Bonne chance pour l'utilisation de la minuterie à neuf canaux.
- // 02. Le premier timer a démarré.
- // 03. Le deuxième timer a démarré.
- // 04. La troisième minuterie a commencé.
- // 05. La quatrième minuterie a démarré.
- // 06. La cinquième minuterie a commencé.
- // 07. La sixième minuterie a commencé.
- // 08. La septième minuterie a commencé.
- // 09. La huitième minuterie a commencé.
- // 10. La neuvième minuterie a commencé.
- // 11. Le premier temporisateur a expiré.
- // 12. La deuxième minuterie a expiré.
- // 13. La troisième minuterie a expiré.
- // 14. La quatrième minuterie a expiré.
- // 15. La cinquième minuterie a expiré.
- // 16. La sixième minuterie a expiré.
- // 17. La septième minuterie a expiré.
- // 18. La huitième minuterie a expiré.
- // 19. La neuvième minuterie a expiré.
- //
- // 4. Spanish speaking
- // 01. ¡Bienvenidos! Buena suerte con el temporizador de nueve canales.
- // 02. El primer temporizador ha comenzado.
- // 03. El segundo temporizador ha comenzado.
- // 04. El tercer temporizador ha comenzado.
- // 05. El cuarto temporizador ha comenzado.
- // 06. El quinto temporizador ha comenzado.
- // 07. El sexto temporizador ha comenzado.
- // 08. El séptimo temporizador ha comenzado.
- // 09. El octavo temporizador ha comenzado.
- // 10. El noveno temporizador ha comenzado.
- // 11. El primer temporizador ha expirado.
- // 12. El segundo temporizador ha expirado.
- // 13. El tercer temporizador ha expirado.
- // 14. El cuarto temporizador ha expirado.
- // 15. El quinto temporizador ha expirado.
- // 16. El sexto temporizador ha expirado.
- // 17. El séptimo temporizador ha expirado.
- // 18. El octavo temporizador ha expirado.
- // 19. El noveno temporizador ha expirado.
- //
- // 5. Hungarian speaking
- // 01. Üdvözöllek! Sok sikert a kilenc csatornás időzítő használatához.
- // 02. Az első időzítő elindult.
- // 03. A második időzítő elindult.
- // 04. A harmadik időzítő elindult.
- // 05. A negyedik időzítő elindult.
- // 06. Az ötödik időzítő elindult.
- // 07. A hatodik időzítő elindult.
- // 08. A hetedik időzítő elindult.
- // 09. A nyolcadik időzítő elindult.
- // 10. A kilencedik időzítő elindult.
- // 11. Lejárt az első időzítő.
- // 12. Lejárt a második időzítő.
- // 13. Lejárt a harmadik időzítő.
- // 14. Lejárt a negyedik időzítő.
- // 15. Lejárt az ötödik időzítő.
- // 16. Lejárt a hatodik időzítő.
- // 17. Lejárt a hetedik időzítő.
- // 18. Lejárt a nyolcadik időzítő.
- // 19. Lejárt a kilencedik időzítő.
- //
- // end text
- customchar.h
- byte s0[8] = {
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- };
Add Comment
Please, Sign In to add comment