-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWFM_v222.ino
965 lines (761 loc) · 23.1 KB
/
WFM_v222.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
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
#define Testing 0
// Define button constants
#define btnRIGHT 1
#define btnUP 2
#define btnDOWN 3
#define btnLEFT 4
#define btnSELECT 5
#define btnNONE 0
#define MaxHeatingTime 5 // 5 sec
#define PresetHeatingTime 2 // 2 sec
#define PresetBasePower 80 // PWM 80% of full machine power as for standard L&H 0.018 X 0.025
#define Pedal_Pin 2
#define Buzz_Pin 3
#define IR_ObstaclePin 12
#define PWM_Pin 11
// You can have up to 10 menu items in the menuItems[] array below without having to change the base programming at all. Name them however you'd like. Beyond 10 items, you will have to add additional "cases" in the switch/case
// section of the operateMainMenu() function below. You will also have to add additional void functions (i.e. menuItem11, menuItem12, etc.) to the program.
String menuItems[] = {"L&H 018*025", "L&H 016*022", "Ni-Ti 021*025", "Ni-Ti 018(Rnd)", "Form Manually", "PWR Adjustment"};
//int FlagToHeat = 0; // Flag to indicate ready to heat wire
float WireSpec = 1.0; // Base wire as NiTi 0.018 X0.025
// Navigation button variables
int readKey = 0;
int savedDistance = 0;
int isStartingUp = 1;
int SettedPowerLevel = 4; // middle on 1-7 scale, every scale increase/decrease 3.3%
// Menu control variables
int menuPage = 0;
int maxMenuPages = round(((sizeof(menuItems) / sizeof(String)) / 2) + .5);
int cursorPosition = 0;
int activeButton = 0;
// Creates 3 custom characters for the menu display
byte downArrow[8] = {
0b00100, // *
0b00100, // *
0b00100, // *
0b00100, // *
0b00100, // *
0b10101, // * * *
0b01110, // ***
0b00100 // *
};
byte upArrow[8] = {
0b00100, // *
0b01110, // ***
0b10101, // * * *
0b00100, // *
0b00100, // *
0b00100, // *
0b00100, // *
0b00100 // *
};
byte menuCursor[8] = {
B01000, // *
B00100, // *
B00010, // *
B00001, // *
B00010, // *
B00100, // *
B01000, // *
B00000 //
};
// (C)
byte CharCopyright[8] = {
B01110,
B10001,
B10101,
B10111,
B10101,
B10001,
B01110,
B00000
};
// (R)
byte CharRegistered[8] = {
B11111,
B10001,
B10101,
B10001,
B10011,
B10101,
B11111,
B00000
};
// filled
byte CharFilled[8] = {
B00000, //
B11111, // *****
B11111, // *****
B11111, // *****
B11111, // *****
B11111, // *****
B11111, // *****
B00000 //
};
// (R)
byte CharEmpty[8] = {
B00000,
B11111,
B10001,
B10001,
B10001,
B10001,
B11111,
B00000
};
#include <Wire.h>
#include <LiquidCrystal.h>
// Setting the LCD shields pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// Initializes serial communication
Serial.begin(9600);
pinMode(IR_ObstaclePin, INPUT);
pinMode(Buzz_Pin, OUTPUT);
pinMode(PWM_Pin, OUTPUT);
pinMode(Pedal_Pin, INPUT_PULLUP);
// Initializes and clears the LCD screen
lcd.begin(16, 2);
lcd.clear();
// Creates the byte for the 3 custom characters
lcd.createChar(0, menuCursor);
lcd.createChar(1, upArrow);
lcd.createChar(2, downArrow);
lcd.createChar(3, CharCopyright);
lcd.createChar(4, CharRegistered);
lcd.createChar(5, CharFilled);
lcd.createChar(6, CharEmpty);
}
//**********************
void loop() {
OpeningHello();
mainMenuDraw();
drawCursor();
operateMainMenu();
}
//**********************
void OpeningHello(){
int activeButton = 0;
// Opening Hello string display
Serial.print("\nisStarting = ");
Serial.print(isStartingUp);
if (isStartingUp != 1) {
return;
}
isStartingUp = 0;
Serial.print("\nisStarting = ");
Serial.print(isStartingUp);
//flash on/off data loading....
for(int n=0; n<8; n++){
lcd.clear();
lcd.setCursor(1,0);
lcd.print("Data loading...");
delay(300);
lcd.clear();
lcd.setCursor(1,0);
lcd.print(" ");
delay(300);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("EZWFormer");
lcd.write(3);
lcd.print(" V2.2");
lcd.setCursor(0,1);
//lcd.print("any key to start..."); //Need to scroll string here!
lcd.print(" ");
lcd.blink();
delay(2000);
if (ReadPressedKeypadA0() != btnNONE) { // Read any keypad input
lcd.noBlink();
}
//Serial.print("\nreadKey = ");
//Serial.print(evaluateButton(readKey));
}
//-------------------------End of OpenningHello()
//while loop to wait for any key to be pressed, twice analogRead() of Pin A0
int ReadPressedKeypadA0() { //------------------------------------------
int activeButton = 0;
while (activeButton == 0) {
readKey = analogRead(0);
Serial.print("\nreadKey1 = ");
Serial.print(readKey);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
//Serial.print("\nreadKey2 = ");
//Serial.print(readKey);
}
if (evaluateButton(readKey) != btnNONE){
activeButton = 1; // any key pressed
}
}
return evaluateButton(readKey);
}//---------------------------End of ReadPressedKeypadA0()
//while loop to wait for LEFT to return, or Pedal pressed or IR detected
int ReadHeatSignal(int HeatingMode, float Spec) { //------------------------------------------
int i=0;
int j=0;
readKey = analogRead(0);
while ( i != btnLEFT ) {
readKey = analogRead(0);
//Serial.print("\nreadKey1 in HeatSignal = ");
//Serial.print(readKey);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
}
delay(50);
j = evaluateButton(readKey);
if ((j == btnLEFT)|| (j == btnSELECT)){
return 0;
}
i = IRDetected();
if (i == 1) {
ToHeatWire(HeatingMode, Spec);
} else {
Serial.println("IR off");
}
delay(50);
i = PedalPressed();
if (i == 1) {
ToHeatWire(HeatingMode, Spec);
} else {
Serial.println("Pedal not pressed");
}
delay(50);
}
}//---------------------------End of ReadHeatSignal()
void ToHeatWire(int HeatingMode, float Spec){
int i;
float j;
//Serial.println("\nNow heating is going on ");
//Serial.println(HeatingMode);
//digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
//for(i=0;i<HeatingMode;i++){
//digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
//delay(500);
//digitalWrite(Buzz_Pin, LOW); // turn off buzzor
//delay(250);
//}
j = PresetBasePower*(1+(SettedPowerLevel-4)*0.033)*Spec;
if ( j > 99.5){
i=100;
} else {
i= round(PresetBasePower*(1+(SettedPowerLevel-4)*0.033)*Spec);
}
Serial.println("i = ");
Serial.println(i);
Serial.println("SetPowerLvl = ");
Serial.println(SettedPowerLevel);
Serial.println("WireSpec = ");
Serial.println(WireSpec);
// PresetBasePower * Setted power level 1-7 * WireSpec = 1 for TiNi 0.018 X 0.025
//Serial.print("\nStart heating Mode = "); Serial.print(HeatingMode);
if(HeatingMode != 5) {
digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(i,1,100,0,255)); // turn on PWM heat output
delay(round(PresetHeatingTime*1000)); //2 X 1 second
analogWrite(PWM_Pin, map(1,1,100,0,255)); // turn off PWM heat output
digitalWrite(Buzz_Pin, LOW); //// turn off buzzor
delay(8000); // wait for 9 sec after each heating
} else { // Apply pwm to MOSFET maximum duration
digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(i,1,100,0,255)); // turn on PWM heat output
delay(round(MaxHeatingTime*1000)); // 5 sec
analogWrite(PWM_Pin, map(1,1,100,0,255)); // turn off PWM heat output
digitalWrite(Buzz_Pin, LOW); //// turn off buzzor
delay(8000); // wait for 9 sec after each heating
}
} // -------------------------End of ToHeatWire(int HeatingMode)
void PowerLevelPage(){
int btn =0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Power Level");
LevelIndicatorBar(SettedPowerLevel);
while (btn != btnSELECT ){
btn = ReadPressedKeypadA0();
//Serial.print(btn);
if((btn == btnUP)&& (SettedPowerLevel < 7 )){
SettedPowerLevel++;
LevelIndicatorBar(SettedPowerLevel);
}
if((btn == btnDOWN)&& (SettedPowerLevel >1)) {
SettedPowerLevel--;
LevelIndicatorBar(SettedPowerLevel);
}
}
}//---------------------------End of PowerLevelPage()
void LevelIndicatorBar(int level){
int i;
lcd.setCursor(0,4);
lcd.write(1);// up arrow
for(i=0;i<level;i++) lcd.write(5); // filled char
for(i=0;i<(7-level);i++) lcd.write(6); // empty char
lcd.write(2);// down arrow
}//---------------------------End of LevelIndicatorBar()
/*
void HeatWire(int HeatingMode) { // -------------
int i;
i = round((PresetBasePower*(1+(SettedPowerLevel-4)*0.03)*WireSpec));
// PresetBasePower * Setted power level 1-7 * WireSpec = 1 for TiNi 0.018 X 0.025
Serial.print("\nStart heating Mode = "); Serial.print(HeatingMode);
if(HeatingMode != 5) {
digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(i,1,100,0,255)); // turn on PWM heat output
delay(round(PresetHeatingTime*1000));
analogWrite(PWM_Pin, map(1,1,100,0,255)); // turn off PWM heat output
digitalWrite(Buzz_Pin, LOW); //// turn off buzzor
delay(9000); // wait for 9 sec after each heating
} else { // Apply pwm to MOSFET maximum duration
digitalWrite(Buzz_Pin, HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(i,1,100,0,255)); // turn on PWM heat output
delay(round(MaxHeatingTime*1000));
analogWrite(PWM_Pin, map(1,1,100,0,255)); // turn off PWM heat output
digitalWrite(Buzz_Pin, LOW); //// turn off buzzor
delay(9000); // wait for 9 sec after each heating
}
} //--------------------End of ToHeatWire()
*/
int PedalPressed(){ // Pedal 2 terminal connected with 0.1uF capacitor
int isPressed;
if (digitalRead(Pedal_Pin) == LOW)
{
Serial.println("Pressed!!, Pressed!!");
//delay(2000);
//digitalWrite(LED, HIGH);
isPressed = 1;
return isPressed;
}
else
{
//Serial.println("clear");
//digitalWrite(LED, LOW);
Serial.println("not Pressed!!, not Pressed!!");
isPressed = 0;
return isPressed;
}
} // ------------------End of PedalPressed()
int IRDetected(){ // For FC-51 IR obstacle module
int isObstacle;
if (digitalRead(IR_ObstaclePin) == HIGH)
{
//Serial.println("OBSTACLE!!, OBSTACLE!!");
//digitalWrite(LED, HIGH);
isObstacle = 1;
return isObstacle;
}
else
{
//Serial.println("clear");
//digitalWrite(LED, LOW);
isObstacle = 0;
return isObstacle;
}
} // ------------------End of IRDetected()
// This function will generate the 2 menu items that can fit on the screen.
// They will change as you scroll through your menu. Up and down arrows will indicate your current menu position.
void mainMenuDraw() {
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(menuItems[menuPage]);
lcd.setCursor(1, 1);
lcd.print(menuItems[menuPage + 1]);
if (menuPage == 0) {
lcd.setCursor(15, 1);
lcd.write(byte(2)); //arrow down only
} else if (menuPage > 0 and menuPage < maxMenuPages) {
lcd.setCursor(15, 1);
lcd.write(byte(2)); // arrow down
lcd.setCursor(15, 0);
lcd.write(byte(1)); // arrow up
} else if (menuPage == maxMenuPages) {
lcd.setCursor(15, 0);
lcd.write(byte(1)); //arrow up only
}
}//----------------End of mainMenuDraw()
// When called, this function will erase the current cursor and redraw it based on the cursorPosition and menuPage variables.
void drawCursor() {
for (int x = 0; x < 2; x++) { // Erases current cursor
lcd.setCursor(0, x);
lcd.print(" ");
}
// The menu is set up to be progressive (menuPage 0 = Item 1 & Item 2, menuPage 1 = Item 2 & Item 3, menuPage 2 = Item 3 & Item 4), so
// in order to determine where the cursor should be you need to see if you are at an odd or even menu page and an odd or even cursor position.
if (menuPage % 2 == 0) {
if (cursorPosition % 2 == 0) { // If the menu page is even and the cursor position is even that means the cursor should be on line 1
lcd.setCursor(0, 0);
lcd.write(byte(0));
}
if (cursorPosition % 2 != 0) { // If the menu page is even and the cursor position is odd that means the cursor should be on line 2
lcd.setCursor(0, 1);
lcd.write(byte(0));
}
}
if (menuPage % 2 != 0) {
if (cursorPosition % 2 == 0) { // If the menu page is odd and the cursor position is even that means the cursor should be on line 2
lcd.setCursor(0, 1);
lcd.write(byte(0));
}
if (cursorPosition % 2 != 0) { // If the menu page is odd and the cursor position is odd that means the cursor should be on line 1
lcd.setCursor(0, 0);
lcd.write(byte(0));
}
}
}
void operateMainMenu() {
int activeButton = 0;
while (activeButton == 0) {
int button;
readKey = analogRead(0);
if (readKey < 790);0; {
delay(100);
readKey = analogRead(0);
}
button = evaluateButton(readKey);
switch (button) {
case btnNONE: // When button returns as 0 there is no action taken
break;
case btnRIGHT: // This case will execute if the "right" button is pressed
button = 0;
switch (cursorPosition) { // The case that is selected here is dependent on which menu page you are on and where the cursor is.
case 0:
menuItem1();
break;
case 1:
menuItem2();
break;
case 2:
menuItem3();
break;
case 3:
menuItem4();
break;
case 4:
menuItem5();
break;
case 5:
menuItem6();
break;
case 6:
menuItem7();
break;
case 7:
menuItem8();
break;
case 8:
menuItem9();
break;
case 9:
menuItem10();
break;
}
activeButton = 1;
mainMenuDraw();
drawCursor();
break;
case btnUP:
button = 0;
if (menuPage == 0) {
cursorPosition = cursorPosition - 1;
cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));
}
if (menuPage % 2 == 0 and cursorPosition % 2 == 0) {
menuPage = menuPage - 1;
menuPage = constrain(menuPage, 0, maxMenuPages);
}
if (menuPage % 2 != 0 and cursorPosition % 2 != 0) {
menuPage = menuPage - 1;
menuPage = constrain(menuPage, 0, maxMenuPages);
}
cursorPosition = cursorPosition - 1;
cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));
mainMenuDraw();
drawCursor();
activeButton = 1;
break;
case btnDOWN:
button = 0;
if (menuPage % 2 == 0 and cursorPosition % 2 != 0) {
menuPage = menuPage + 1;
menuPage = constrain(menuPage, 0, maxMenuPages);
}
if (menuPage % 2 != 0 and cursorPosition % 2 == 0) {
menuPage = menuPage + 1;
menuPage = constrain(menuPage, 0, maxMenuPages);
}
cursorPosition = cursorPosition + 1;
cursorPosition = constrain(cursorPosition, 0, ((sizeof(menuItems) / sizeof(String)) - 1));
mainMenuDraw();
drawCursor();
activeButton = 1;
break;
}
}
}
// This function is called whenever a button press is evaluated. The LCD shield works by observing a voltage drop across the buttons all hooked up to A0.
int evaluateButton(int x) {
int result = btnNONE;
if (x < 60) {
result = btnRIGHT;
} else if (x < 195) {
result = btnUP;
} else if (x < 380) {
result = btnDOWN;
} else if (x < 555) {
result = btnLEFT;
} else if (x < 790) {
result = btnSELECT;
} else if (x > 1000) {
result = btnNONE;
}
return result;
}
// If there are common usage instructions on more than 1 of your menu items you can call this function from the sub
// menus to make things a little more simplified. If you don't have common instructions or verbage on multiple menus
// I would just delete this void. You must also delete the drawInstructions()function calls from your sub menu functions.
void drawInstructions() {
lcd.setCursor(0, 1); // Set cursor to the bottom line
lcd.print("Use ");
lcd.write(byte(1)); // Up arrow
lcd.print("/");
lcd.write(byte(2)); // Down arrow
lcd.print(" buttons");
}
void menuItem1() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Ready to form...");
lcd.setCursor(2, 1);
lcd.print(menuItems[0]);
//WireSpec = 1; // Base Wire spec as for NiTi 0.018 X 0.025 archwire
ReadHeatSignal(1, 1.0);
}
void menuItem2() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Ready to form...");
lcd.setCursor(2, 1);
lcd.print(menuItems[1]);
//WireSpec = 0.7822; // Base Wire spec as for NiTi 0.016 X 0.022 archwire adjusted 0.91
ReadHeatSignal(2, 0.82);
}
void menuItem3() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Ready to form...");
lcd.setCursor(2, 1);
lcd.print(menuItems[2]);
//WireSpec = 1.166; // Base Wire spec as for NiTi round 0.021 X 0.025 archwire
ReadHeatSignal(3, 1.166);
}
void menuItem4() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Ready to form...");
lcd.setCursor(2, 1);
lcd.print(menuItems[3]);
//WireSpec = 0.565; //(3.14*(18/2)*(18/2))/(18*25); // Base Wire spec as for NiTi round 0.018 archwire
ReadHeatSignal(4, 0.65); // adjusted for non linear factor
}
void menuItem5() {
//int prevPWR;
//prevPWR = SettedPowerLevel;
//PowerLevelPage(); // Set power level page
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(menuItems[4]);
lcd.setCursor(2, 1);
lcd.print(" up to 5 sec.");
//WireSpec = 1; // Base Wire spec as for NiTi round 0.018 archwire
ReadHeatSignal(5, 1.0);
//SettedPowerLevel = prevPWR; // reset the previous PWR setting
}//---------End of menuItem5()
/*
// testing by 10 20 30 40 50% for 5 sec.
void menuItem5() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Testing 5 sec...");
lcd.setCursor(2, 1);
lcd.print("From 30% to 100% ");
delay(3000);
lcd.setCursor(2, 1);
lcd.print("30% 30% 30%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(30,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("40% 40% 40%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(40,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("50% 50% 50%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(50,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("60% 60% 60%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(60,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("70% 70% 70%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(70,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("80% 80% 80%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(80,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("90% 90% 90%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(90,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
delay(3000);
lcd.setCursor(2, 1);
lcd.print("100% 100% 100%");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(100,1,100,0,255));
delay(5000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
}//---------End of menuItem5() test
*/
void menuItem6() { //if Testing mode, do testing
int i;
if(Testing == 1){
for(i=0;i<100;i++) {
lcd.setCursor(1, 0);
lcd.print("Testing......");
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
analogWrite(PWM_Pin, map(90,1,100,0,255));
delay(3000);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
analogWrite(PWM_Pin, map(1,1,100,0,255));
lcd.setCursor(2, 1);
lcd.print("90% PWM PWR");
delay(1000);
}
}
PowerLevelPage(); // Set power level page
lcd.clear();
lcd.setCursor(3,0);
lcd.print(" PWR Setting");
lcd.setCursor(5,1);
lcd.print(" Saved");
lcd.blink();
digitalWrite(Buzz_Pin,HIGH); // turn on buzzor
delay(300);
digitalWrite(Buzz_Pin,LOW); // turn off buzzor
delay(1000);
lcd.noBlink();
}
void menuItem7() { // Function executes when you select the 7th item from main menu
int activeButton = 0;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Sub Menu 7");
while (activeButton == 0) {
int button;
readKey = analogRead(0);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
}
button = evaluateButton(readKey);
switch (button) {
case 4: // This case will execute if the "back" button is pressed
button = 0;
activeButton = 1;
break;
}
}
}
void menuItem8() { // Function executes when you select the 8th item from main menu
int activeButton = 0;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Sub Menu 8");
while (activeButton == 0) {
int button;
readKey = analogRead(0);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
}
button = evaluateButton(readKey);
switch (button) {
case 4: // This case will execute if the "back" button is pressed
button = 0;
activeButton = 1;
break;
}
}
}
void menuItem9() { // Function executes when you select the 9th item from main menu
int activeButton = 0;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Sub Menu 9");
while (activeButton == 0) {
int button;
readKey = analogRead(0);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
}
button = evaluateButton(readKey);
switch (button) {
case 4: // This case will execute if the "back" button is pressed
button = 0;
activeButton = 1;
break;
}
}
}
void menuItem10() { // Function executes when you select the 10th item from main menu
int activeButton = 0;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Sub Menu 10");
while (activeButton == 0) {
int button;
readKey = analogRead(0);
if (readKey < 790) {
delay(100);
readKey = analogRead(0);
}
button = evaluateButton(readKey);
switch (button) {
case 4: // This case will execute if the "back" button is pressed
button = 0;
activeButton = 1;
break;
}
}
}