// constants won't change. They're used here to
// set pin numbers:
const int buttonPinA = A0;
const int ledPinA = 11;
const int buttonPinB = A1;
const int ledPinB = 10;
const int buttonPinC = A2;
const int ledPinC = 9;
const int buttonPinD = A3;
const int ledPinD = 6;
const int buttonPinE = A4;
const int ledPinE = 5;
const int buttonPinF = A5;
const int ledPinF = 3;
// variables will change:
int buttonStateA = 0;
int buttonStateB = 0;
int buttonStateC = 0;
int buttonStateD = 0;
int buttonStateE = 0;
int buttonStateF = 0;
void setup() {
pinMode(ledPinA, OUTPUT);
pinMode(buttonPinA, INPUT);
pinMode(ledPinB, OUTPUT);
pinMode(buttonPinB, INPUT);
pinMode(ledPinC, OUTPUT);
pinMode(buttonPinC, INPUT);
pinMode(ledPinD, OUTPUT);
pinMode(buttonPinD, INPUT);
pinMode(ledPinE, OUTPUT);
pinMode(buttonPinE, INPUT);
pinMode(ledPinF, OUTPUT);
pinMode(buttonPinF, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonStateA = digitalRead(buttonPinA);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateA == HIGH) {
// turn LED on:
digitalWrite(ledPinA, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinA, LOW);
}
// read the state of the pushbutton value:
buttonStateB = digitalRead(buttonPinB);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateB == HIGH) {
// turn LED on:
digitalWrite(ledPinB, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinB, LOW);
}
// read the state of the pushbutton value:
buttonStateC = digitalRead(buttonPinC);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateC == HIGH) {
// turn LED on:
digitalWrite(ledPinC, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinC, LOW);
}
// read the state of the pushbutton value:
buttonStateD = digitalRead(buttonPinD);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateD == HIGH) {
// turn LED on:
digitalWrite(ledPinD, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinD, LOW);
}
// read the state of the pushbutton value:
buttonStateE = digitalRead(buttonPinE);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateE == HIGH) {
// turn LED on:
digitalWrite(ledPinE, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinE, LOW);
}
// read the state of the pushbutton value:
buttonStateF = digitalRead(buttonPinF);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateF == HIGH) {
// turn LED on:
digitalWrite(ledPinF, HIGH);
} else {
// turn LED off:
digitalWrite(ledPinF, LOW);
}
}