Buzzer SOS Signal — Arduino Uno simulation

Proyek buzzer yang memainkan pola Morse SOS menggunakan tone()

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by belvaclairina006.

Components

Sketch code

// Buzzer + LED SOS - nyala & bunyi sinkron
const int buzzerPin = 8;
const int ledPin    = 13;

int dotDuration = 250;
int dashDuration = dotDuration * 3;
int gapBetweenSignal = dotDuration;
int gapBetweenLetter = dotDuration * 3;
int freq = 1000;

void setup() {
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void beepAndFlash(int duration) {
  tone(buzzerPin, freq, duration);
  digitalWrite(ledPin, HIGH);
  delay(duration);
  noTone(buzzerPin);
  digitalWrite(ledPin, LOW);
}

void loop() {
  // --- S (3 titik) ---
  for (int i = 0; i < 3; i++) {
    beepAndFlash(dotDuration);
    delay(gapBetweenSignal);
  }
  delay(gapBetweenLetter);

  // --- O (3 garis) ---
  for (int i = 0; i < 3; i++) {
    beepAndFlash(dashDuration);
    delay(gapBetweenSignal);
  }
  delay(gapBetweenLetter);

  // --- S (3 titik) ---
  for (int i = 0; i < 3; i++) {
    beepAndFlash(dotDuration);
    delay(gapBetweenSignal);
  }

  delay(3000); // jeda sebelum mengulang
}

More projects by belvaclairina006