Can I toggle between 2 or more sketches?
///////////////////////// SKETCH #1 /////////////////////////////
//Arrays to 2 PIN I/O:
int outPin[] = {2,3};
int inPin[] = {22,23};
int pin_size = 2;
int loop_count = 0;
int voltage;
void setup() {
lcd.init();
lcd.backlight();
//initialize the digital pin as an output or input:
pinMode((int)outPin, OUTPUT);
pinMode((int)inPin, INPUT);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0,0);
lcd.print("welcome");
lcd.setCursor(0,1);
lcd.print("by: HERE");
delay(10000);
lcd.clear();
}
void loop() {
// Send the outputs.
digitalWrite(outPin[loop_count], HIGH);
delay(100);
digitalWrite(outPin[loop_count], LOW);
delay(100);
// Receive the inputs:
voltage = digitalRead(inPin[loop_count]);
lcd.print ("Wire " + String(inPin[loop_count]) + ": ");
// LCD prints PASS or FAIL status using a switch statement:
switch (voltage){
case HIGH:
lcd.print("PASS");
break;
case LOW:
lcd.print("FAIL");
break;
default:
lcd.print("UNKNOWN");
}
// Delay and increment the loop counter for the next set of pins.
delay(1000);
loop_count++;
lcd.clear();
// Check if reached the end of all pins.
if (loop_count == pin_size){
lcd.print ("Test Completed");
delay(2000);
lcd.clear();
lcd.print("Testing again...");
delay(1000);
lcd.clear();
loop_count = 0;
}
}
}
///////////////////////// SKETCH #2 /////////////////////////////
//Arrays to 4 PIN I/O:
int outPin[] = {2,3,4,5};
int inPin[] = {22,23,24,25};
int pin_size = 4;
int loop_count = 0;
int voltage;
void setup() {
lcd.init();
lcd.backlight();
//initialize the digital pin as an output or input:
pinMode((int)outPin, OUTPUT);
pinMode((int)inPin, INPUT);
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0,0);
lcd.print("TEST");
lcd.setCursor(0,1);
lcd.print("by: TEST");
delay(10000);
lcd.clear();
}
void loop() {
// Send the outputs.
digitalWrite(outPin[loop_count], HIGH);
delay(100);
digitalWrite(outPin[loop_count], LOW);
delay(100);
// Receive the inputs:
voltage = digitalRead(inPin[loop_count]);
lcd.print ("Wire " + String(inPin[loop_count]) + ": ");
// LCD prints PASS or FAIL status using a switch statement:
switch (voltage){
case HIGH:
lcd.print("PASS");
break;
case LOW:
lcd.print("FAIL");
break;
default:
lcd.print("UNKNOWN");
}
// Delay and increment the loop counter for the next set of pins.
delay(1000);
loop_count++;
lcd.clear();
// Check if reached the end of all pins.
if (loop_count == pin_size){
lcd.print ("Test Completed");
delay(2000);
lcd.clear();
lcd.print("Testing again...");
delay(1000);
lcd.clear();
loop_count = 0;
}
}
}