#define falador 8
const uint8_t botoes_coloridos[] = {11,10};
const uint8_t leds_coloridos[] = {3, 2};
const int notas_botoes[] = {3136, 2637};
const int numTones = sizeof(botoes_coloridos) / sizeof(botoes_coloridos[0]);
const int numLeds = sizeof(leds_coloridos) / sizeof(leds_coloridos[0]);
void setup() {
// put your setup code here, to run once:
for (uint8_t i = 0; i < numTones; i++) {
pinMode(botoes_coloridos[i], INPUT_PULLUP);
}
for (uint8_t i = 0; i < numLeds; i++){
pinMode(leds_coloridos[i], OUTPUT);
}
pinMode(falador, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int pitch = 0;
int led;
for (uint8_t i = 0; i < numTones; i++) {
if (digitalRead(botoes_coloridos[i]) == LOW) {
pitch = notas_botoes[i];
led = leds_coloridos[i];
}
}
if (pitch) {
tone(falador, pitch);
digitalWrite(led, HIGH);
}
else {
noTone(falador);
}
if (digitalRead(led) == HIGH)
{digitalWrite(led, LOW);}
}