-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPLC_Date_Time_ver_4_IR.ino
884 lines (766 loc) · 20.1 KB
/
PLC_Date_Time_ver_4_IR.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
#include <TimeLib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <DS1307RTC.h>
#include <IRremote.h>
tmElements_t tm;
const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
#define TIME_HEADER "T" // Header tag for serial time sync message
//void setRTC();
void readRTC();
void relay1Trigger(int MinuteON, int MinuteOFF, bool *Trigger);
void relay2Trigger(int HourON, int MinuteON, int HourOFF, int MinuteOFF, bool *Trigger);
void relay3Trigger(int HourON, int MinuteON, int HourOFF, int MinuteOFF, bool *Trigger);
void relay4Trigger(int HourON, int MinuteON, int HourOFF, int MinuteOFF, bool *Trigger);
//unsigned long processSyncMessage();
void addZero(int setNumber,int column, int row);
void displayLCD();
void translateIR(); // takes action based on IR code received
//PLC Pin Definition Mapping
int relay1=2;
int relay2=3;
int relay3=4;
int relay4=5;
int relay5=A2;
int relay6=A3;
int receiver = 7; // Signal Pin of IR receiver to Arduino Digital Pin 7 , which is Digital input 1 on PLC
bool parse=false;
bool config=false;
bool powerOn;
//*****************Relay 1 Continuous Operation Parameters********************************
static bool flag1;
static bool flag2;
bool triggerON1;
int delta=2;// increment time change between OFFold/ONold and OFFnew/ONnew
int timediff;//difference between OnN and OFF time
int minuteOFF1old;
int minuteON1old;
int minuteON1=50;
int minuteOFF1=51;
//*****************Relay 2 Hour and Minutes Parameters***********************************
bool triggerON2;
int hourON2=16;
int minuteON2=50;
int hourOFF2=16;
int minuteOFF2=51;
//*****************Relay 3 Hour, and Minutes Parameters*******************************
bool triggerON3;
int hourON3=16;
int minuteON3=55;
int hourOFF3=16;
int minuteOFF3=56;
//*****************Relay 4 Hour, and Minutes Parameters*************************
bool triggerON4;
int hourON4=17;
int minuteON4=1;
int hourOFF4=17;
int minuteOFF4=30;
//***********************IR and decode instances*********************************
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
void setup()
{
lcd.init();
lcd.backlight();
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
Serial.begin(9600);
while (!Serial) ; // Needed for Leonardo only
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
//******** describing Remote IR codes ************
Serial.println("IR Receiver Button Decode");
irrecv.enableIRIn(); // Start the receiver
}
//**********Looping Function******************************
void loop()
{
//************Infra Red Remote Control******************
if (irrecv.decode(&results) )// have we received an IR signal?
{
translateIR();
irrecv.resume(); // receive the next value
}
delay(100);
readRTC();
if(powerOn==HIGH)
{
//readRTC(); // Real Time Clock
//delay(1000);
//displayLCD();
relay1Trigger(minuteON1, minuteOFF1, &triggerON1);
relay2Trigger(hourON2, minuteON2,hourOFF2, minuteOFF2, &triggerON2);
relay3Trigger(hourON3, minuteON3,hourOFF3, minuteOFF3, &triggerON3);
relay4Trigger(hourON4, minuteON4,hourOFF4, minuteOFF4, &triggerON4);
if(triggerON1 || triggerON2)
digitalWrite(relay5,true); // any of relays 1 OR 2 ==true, turn on relay 5
else
digitalWrite(relay5,false);
if(triggerON1 && triggerON2 )
digitalWrite(relay6,true); // all of relays 1 AND 2 ==true, turn on relay 6
else
digitalWrite(relay6,false);
}
lcd.setCursor(0,1);
lcd.print("Time: ");
addZero(tm.Hour,6, 1);
lcd.setCursor(8,1);
lcd.print("/");
addZero(tm.Minute,9, 1);
lcd.setCursor(11,1);
lcd.print("/");
addZero(tm.Second,12, 1);
}
//*************************Trigger Relay 1 at date*********************************
void relay1Trigger(int MinuteON, int MinuteOFF, bool *Trigger)
{
int triggerTime;
if( tm.Minute==MinuteON )
{
*Trigger=true;
flag1=true;
flag2=true;
}
else if(tm.Minute==MinuteOFF )
{
*Trigger=false;
triggerTime=tm.Minute;
if(flag1==true)
{
minuteOFF1old=minuteOFF1;
minuteON1old=minuteON1;
minuteON1=minuteON1+delta;
minuteOFF1=minuteOFF1+delta;
flag1=false;
}
}
if((tm.Minute==0) && (flag2==true))//if statements accomodate change in minutes from 59 to 0
{
if(tm.Minute==(minuteOFF1-60))
*Trigger=false;
if(tm.Minute==(minuteON1-60))
*Trigger=true;
timediff=minuteOFF1-minuteON1;// minuteOFFold and minuteONold
minuteON1=delta+minuteON1old-60;//minuteONnew, minuteOFFold
minuteOFF1=minuteON1+timediff;//minuteOFFnew, minuteONnew
flag2=false;
}
digitalWrite(relay1,*Trigger);
}
//*************************Trigger Relay 2 at date*********************************
void relay2Trigger(int HourON, int MinuteON,int HourOFF, int MinuteOFF, bool *Trigger)
{
if( tm.Hour==HourON && tm.Minute==MinuteON)
{
*Trigger=true;
}
else if(tm.Hour==HourOFF && tm.Minute==MinuteOFF )
{
*Trigger=false;
}
digitalWrite(relay2,*Trigger);
}
//*************************Trigger Relay 3 at date*********************************
void relay3Trigger(int HourON, int MinuteON,int HourOFF, int MinuteOFF, bool *Trigger)
{
if( tm.Hour==HourON && tm.Minute==MinuteON )
{
*Trigger=true;
}
else if(tm.Hour==HourOFF && tm.Minute==MinuteOFF )
{
*Trigger=false;
}
digitalWrite(relay3,*Trigger);
}
//*************************Trigger Relay 4 at date*********************************
void relay4Trigger(int HourON, int MinuteON,int HourOFF, int MinuteOFF, bool *Trigger)
{
if(tm.Hour==HourON && tm.Minute==MinuteON )
{
*Trigger=true;
}
else if(tm.Hour==HourOFF && tm.Minute==MinuteOFF)
{
*Trigger=false;
}
digitalWrite(relay4,*Trigger);
}
//********************IR Control*******************************************
void translateIR() // takes action based on IR code received
// describing Remote IR codes
{
static bool selectRelay1;
static bool selectRelay2;
static bool selectRelay3;
static bool selectRelay4;
static bool flag7;
static bool selectDelta;
static bool selectMinuteON;
static bool selectMinuteOFF;
static bool selectHourON;
static bool selectHourOFF;
int answer = results.value;
Serial.print("answer ");
Serial.println(answer);
switch(results.value)
{
case 0x69AC0569:
if(flag7==LOW)
{
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Scan On ");
powerOn=HIGH;
flag7=HIGH;
}
else if(flag7==HIGH)
{
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Scan Off ");
powerOn=LOW;
flag7=LOW;
digitalWrite(relay1,false);
digitalWrite(relay2,false);
digitalWrite(relay3,false);
digitalWrite(relay4,false);
digitalWrite(relay5,false);
digitalWrite(relay6,false);
lcd.setCursor(0,0);
lcd.print("Date: ");
addZero(tm.Day,5, 0);
lcd.setCursor(7,0);
lcd.print("/");
addZero(tm.Month,8, 0);
lcd.setCursor(10,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print("ScOFF ");
}
break;
case 0x4F7590FD:
selectDelta = true;
selectMinuteON=false;
selectMinuteOFF=false;
selectHourON=false;
selectHourOFF=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Delta ON");
break;
case 0x4F990671:
break;
case 0x81898489: // vol+ selectMinuteON
selectMinuteON=true;
selectMinuteOFF=false;
selectHourON=false;
selectHourOFF=false;
selectDelta=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minute ON");
break;
case 0x3CD37229: // Vol- selectMinuteOFF
selectMinuteOFF=true;
selectMinuteON=false;
selectHourON=false;
selectHourOFF=false;
selectDelta=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minute OFF");
break;
case 0x4AB4D489: // >> selectHourON
selectHourON=true;
selectHourOFF=false;
selectMinuteON=false;
selectMinuteOFF=false;
selectDelta=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Hour ON");
break;
case 0x39CA771D: //<< selectHourOFF
selectHourOFF=true;
selectHourON=false;
selectMinuteON=false;
selectMinuteOFF=false;
selectDelta=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Hour OFF");
break;
case 0xF91004FD: // ^
if (selectRelay1 == true && selectDelta==true)
{
delta=delta+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Delta =");
addZero(delta,10, 0);
}
if (selectRelay1 == true && selectMinuteON==true)
{
minuteON1=minuteON1+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON1 =");
addZero(minuteON1,9, 0);
}
if(selectRelay2==true && selectMinuteON==true)
{
minuteON2=minuteON2+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON2 =");
addZero(minuteON2,9, 0);
}
if(selectRelay3==true && selectMinuteON==true)
{
minuteON3=minuteON3+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON3 =");
addZero(minuteON3,9, 0);
}
if(selectRelay4==true && selectMinuteON==true)
{
minuteON4=minuteON4+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON4 =");
addZero(minuteON4,9, 0);
}
if(selectRelay2==true && selectHourON==true)
{
hourON2=hourON2+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourON2 =");
addZero(hourON2,10, 0);
}
if(selectRelay3==true && selectHourON==true)
{
hourON3=hourON3+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourON3 =");
addZero(hourON3,10, 0);
}
if(selectRelay4==true && selectHourON==true)
{
hourON4=hourON4+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourON4 =");
addZero(hourON4,10, 0);
}
if (selectRelay1 == true && selectMinuteOFF==true)
{
minuteOFF1=minuteOFF1+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF1 =");
addZero(minuteOFF1,9, 0);
}
if(selectRelay2==true && selectMinuteOFF==true)
{
minuteOFF2=minuteOFF2+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF2 =");
addZero(minuteOFF2,9, 0);
}
if(selectRelay3==true && selectMinuteOFF==true)
{
minuteOFF3=minuteOFF3+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF3 =");
addZero(minuteOFF3,9, 0);
}
if(selectRelay4==true && selectMinuteOFF==true)
{
minuteOFF4=minuteOFF4+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF4 =");
addZero(minuteOFF4,9, 0);
}
if(selectRelay2==true && selectHourOFF==true)
{
hourOFF2=hourOFF2+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF2 =");
addZero(hourOFF2,10, 0);
}
if(selectRelay3==true && selectHourOFF==true)
{
hourOFF3=hourOFF3+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF3 =");
addZero(hourOFF3,10, 0);
}
if(selectRelay4==true && selectHourOFF==true)
{
hourOFF4=hourOFF4+1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF4 =");
addZero(hourOFF4,10, 0);
}
break;
case 0x2038C209: // V
if (selectRelay1 == true && selectDelta==true)
{
delta=delta-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Delta =");
addZero(delta,10, 0);
}
if (selectRelay1 == true && selectMinuteON==true)
{
minuteON1=minuteON1-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON1 =");
addZero(minuteON1,9, 0);
}
if(selectRelay2==true && selectMinuteON==true)
{
minuteON2=minuteON2-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON2 =");
addZero(minuteON2,9, 0);
}
if(selectRelay3==true && selectMinuteON==true)
{
minuteON3=minuteON3-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON3 =");
addZero(minuteON3,9, 0);
}
if(selectRelay4==true && selectMinuteON==true)
{
minuteON4=minuteON4-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minON4 =");
addZero(minuteON4,9, 0);
}
if(selectRelay2==true && selectHourON==true)
{
hourON2=hourON2-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("hourON2 =");
addZero(hourON2,10, 0);
}
if(selectRelay3==true && selectHourON==true)
{
hourON3=hourON3-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("hourON3 =");
addZero(hourON3,10, 0);
}
if(selectRelay4==true && selectHourON==true)
{
hourON4=hourON4-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("hourON4 =");
addZero(hourON4,10, 0);
}
if (selectRelay1 == true && selectMinuteOFF==true)
{
minuteOFF1=minuteOFF1-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF1 =");
addZero(minuteOFF1,9, 0);
}
if(selectRelay2==true && selectMinuteOFF==true)
{
minuteOFF2=minuteOFF2-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF2 =");
addZero(minuteOFF2,9, 0);
}
if(selectRelay3==true && selectMinuteOFF==true)
{
minuteOFF3=minuteOFF3-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF3 =");
addZero(minuteOFF3,9, 0);
}
if(selectRelay4==true && selectMinuteOFF==true)
{
minuteOFF4=minuteOFF4-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("minOFF4 =");
addZero(minuteOFF4,9, 0);
}
if(selectRelay2==true && selectHourOFF==true)
{
hourOFF2=hourOFF2-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF2 =");
addZero(hourOFF2,10, 0);
}
if(selectRelay3==true && selectHourOFF==true)
{
hourOFF3=hourOFF3-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF3 =");
addZero(hourOFF3,10, 0);
}
if(selectRelay4==true && selectHourOFF==true)
{
hourOFF4=hourOFF4-1;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("HourOFF4 =");
addZero(hourOFF4,10, 0);
}
break;
case 0x19D26A69:
break;
case 0x6EE1C5C9:
break;
case 0x54B0F149: // 0
break;
case 0xEC7BF6BD: // 1
selectRelay1=true;
selectRelay2=false;
selectRelay3=false;
selectRelay4=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(10,0);
lcd.print("Relay1");
break;
case 0xBC4B615: // 2
selectRelay1=false;
selectRelay2=true;
selectRelay3=false;
selectRelay4=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(10,0);
lcd.print("Relay2");
break;
case 0x70B9ED69: // 3
selectRelay1=false;
selectRelay2=false;
selectRelay3=true;
selectRelay4=false;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(10,0);
lcd.print("Relay3");
break;
case 0x95F2F549: // 4
selectRelay1=false;
selectRelay2=false;
selectRelay3=false;
selectRelay4=true;
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(10,0);
lcd.print("Relay4");
break;
case 0x624DB789: // 5
break;
case 0x52DAE09D: // 6
break;
case 0x7CC8C815: Serial.println("7");
break;
case 0x8B29A149: Serial.println("8");
break;
case 0x762BC369: // 9
break;
}// End Case
//delay(500); // Do not get immediate repeat
} //END translateIR
//*******************Display Functions*********************
void displayLCD()
{
lcd.setCursor(0,1);
lcd.print("Time: ");
addZero(tm.Hour,5, 1);
lcd.setCursor(7,1);
lcd.print("/");
addZero(tm.Minute,8, 1);
lcd.setCursor(10,1);
lcd.print("/");
addZero(tm.Second,11, 1);
lcd.setCursor(0,0);
lcd.print("Date: ");
addZero(tm.Day,5, 0);
lcd.setCursor(7,0);
lcd.print("/");
addZero(tm.Month,8, 0);
lcd.setCursor(10,0);
lcd.print("/");
addZero(tmYearToCalendar(tm.Year),11, 0);
}
void addZero(int setNumber,int column, int row)
{
lcd.setCursor(column, row);
if (setNumber >= 0 && setNumber < 10)
{
lcd.print("0");
lcd.setCursor(column+1,row);
lcd.print(setNumber);
}
else
{
lcd.print(setNumber);
}
}
//******************************Real Time Clock Funtions*******************
void readRTC(){
RTC.read(tm);
}