int dip_switch[8] = {2, 3, 4, 5, 6, 7, 8, 9};
int read_dip_switch[8] = {};
int buzzer = 13;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int i = 0; i<=8; i++) {
pinMode(dip_switch[i], INPUT);
}
pinMode(buzzer, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i<=8; i++) {
read_dip_switch[i] = digitalRead(dip_switch[i]);
}
if (read_dip_switch[0] == true) {
tone(buzzer, 100);
}
else if (read_dip_switch[1] == true) {
tone(buzzer, 200);
}
else if (read_dip_switch[2] == true) {
tone(buzzer, 300);
}
else if (read_dip_switch[3] == true) {
tone(buzzer, 400);
}
else if (read_dip_switch[4] == true) {
tone(buzzer, 500);
}
else if (read_dip_switch[5] == true) {
tone(buzzer, 600);
}
else if (read_dip_switch[6] == true) {
tone(buzzer, 700);
}
else if (read_dip_switch[7] == true) {
tone(buzzer, 800);
}
else {
noTone(buzzer);
}
delay(100);
}