apuntes_Arduino/buzzer/README.md
jp.av.dev 85bf8bb429 proyectos renombrados, reestructuracion
pendientes crear, indexar y linkear readmes
2022-04-04 01:11:04 -04:00

1.0 KiB

Parlantes, Buzzers

2 pots 2 speakers

Control de tiempo y tono

#define pot1 A0
#define pot2 A1
#define pot3 A2
#define pot4 A3

#define spkrL 2
#define spkrR 1

void setup() {
  //pinMode(spkrL, OUTPUT);
  //pinMode(spkrR, OUTPUT);
}

void loop() {
  // tone(pin, frequency, duration)
  int duracionL=map(analogRead(pot3), 0, 1023, 10, 1000);
  int duracionR=map(analogRead(pot4), 0, 1023, 10, 1000);
  int tonoL=map(analogRead(pot1),0, 1023, 60, 5000);
  int tonoR=map(analogRead(pot2),0, 1023, 60, 5000);
  tone(spkrL, tonoL, duracionL);
  delay(duracionL);
  tone(spkrR, tonoR, duracionR);
  delay(duracionR);
  delay(30);
}

Descargar