int n = 10;
void setup() {
// put your setup code here, to run once:
for (int i = 7; i <= 13; i++) pinMode(i, INPUT_PULLUP);
pinMode(2, OUTPUT);
Serial.begin(9600);
pinMode(A0, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int flag = 0;
for (int i = 7; i <= 13; i++) {
n = 10 + (analogRead(A0) / 1024.0 * 200.0);
Serial.print(digitalRead(i));
Serial.print(" ");
if (digitalRead(i) == 0) flag = 1, tone(2, (13 - i + 8) * n);
}
if (flag == 0) noTone(2);
Serial.println();
}