int S7 = 2; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D2
int S6 = 3; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D3
int S5 = 4; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D4
int S4 = 5; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D5
int S3 = 6; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D6
int S2 = 7; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D7
int S1 = 8; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D8
int S0 = 9; // Variable initialization and definition. Variable is an Integer Data type connected to digital pin D9
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(S7, INPUT); //Variable S7 connected to Digital Pin D2 is configured an INPUT
pinMode(S6, INPUT);
pinMode(S5, INPUT);
pinMode(S4, INPUT);
pinMode(S3, INPUT);
pinMode(S2, INPUT);
pinMode(S1, INPUT);
pinMode(S0, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int Switch7=digitalRead(S7); //The value of S7 is stored in container called Switch7
int Switch6=digitalRead(S6);
int Switch5=digitalRead(S5);
int Switch4=digitalRead(S4);
int Switch3=digitalRead(S3);
int Switch2=digitalRead(S2);
int Switch1=digitalRead(S1);
int Switch0=digitalRead(S0);
Serial.print("Switch7: "); //Print a String called Switch7:
Serial.println(Switch7); //Print the value of Switch7 on the next line
Serial.print("Switch6: ");
Serial.println(Switch6);
Serial.print("Switch5: ");
Serial.println(Switch5);
Serial.print("Switch4: ");
Serial.println(Switch4);
Serial.print("Switch3: ");
Serial.println(Switch3);
Serial.print("Switch2: ");
Serial.println(Switch2);
Serial.print("Switch1: ");
Serial.println(Switch1);
Serial.print("Switch0: ");
Serial.println(Switch0);
delay(1000); //delay the printout for an interval of 1000 millisecond(i.e, 1 second)
}