buzzercoba — ESP32-S3 simulation

An interactive ESP32-S3 circuit simulation you can run free in your browser on Velxio, by itsmebenn.

Components

Sketch code

const int buttonPin = 16; 
const int buzzerPin = 15;

bool isBuzzerOn = false; 

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    if (!isBuzzerOn) {
      tone(buzzerPin, 1000); 
      isBuzzerOn = true;
    }
  } else {
    if (isBuzzerOn) {
      noTone(buzzerPin);
      isBuzzerOn = false;
    }
  }
  
  delay(10);
}

More projects by itsmebenn