/*
  Playing Tones based on sliding pot position
  https://wokwi.com/projects/352178590336932865
  by dlloydev, December 2022.
*/

#include <pwmWrite.h>

uint8_t tonePin = 4;
uint8_t potPin = 12;
uint16_t duration = 500;  // tone duration (ms)
uint16_t interval = 0;    // pause between tones (ms)

Pwm pwm = Pwm();  // constructor

void setup() {
  pinMode(potPin, INPUT); // sliding pot input
}

void loop() {
  uint16_t toneVal = analogRead(potPin);
  if (toneVal <= 4) toneVal = 4;
  pwm.tone(tonePin, toneVal, duration, interval);  // auto attaches to ch 0
  delay(10);
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
bz1:1
bz1:2
pot1:VCC
pot1:SIG
pot1:GND