#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
//#include <TM1637Display.h>
#define start_f 6
// define input pins with internal pull-up
#define s90 10
#define s120 11
#define s180 12
#define Test_s 13
int time_scale = 4;
int time_pins[4] = { s90, s120, s180, Test_s };
int move_time;
boolean start_flag = false;
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.clear(); // clear display
lcd.setCursor(0, 0);
int w = 0;
while (w < time_scale) { // sets the time setting ports with internal pull-up
pinMode(time_pins[w], INPUT_PULLUP);
w++;
}
}
void loop() {
lcd.clear(); // clear display
get_move_time();
Start_Button();
} // end of main loop
void get_move_time() {
int time_status[] = { 0, 1, 2, 3 }; // simulate time settings for testing
for (int z = 0; z < time_scale; z++) {
// time_status[z] = digitalRead(time_pin[z]); read switch settings
lcd.clear(); // clear display
move_time = 0; // set default value for testing
lcd.print("Status ");
if (time_status[z] == 0) {
move_time = 10;
} else if (time_status[z] == 1) {
move_time = 20;
} else if (time_status[z] == 2) {
move_time = 30;
}
else if (time_status[z] == 3) {
move_time = 40;
}
lcd.print(time_status[z]);
lcd.print(" ");
lcd.setCursor(9, 1);
lcd.print("M = ");
lcd.print(move_time);
delay(2000);
}
}
void Start_Button() {
lcd.setCursor(0, 0);
//lcd.print("Press to Start");
while (digitalRead(start_f) == false) start_flag = digitalRead(start_f); // remain here until button is pressed
}