Timed Alarm System

Timed Alarm System

Create audible feedback loops. This project demonstrates how to trigger an active buzzer using digital logic to build a standard alarm sequence with precise timing.

Project Goal: Drive an active buzzer on GP0. Implement an asynchronous loop that alternates between a 500ms “Active” state and a 1.5s “Idle” state.

1. Wiring Blueprint

From Component Buzzer Pin Pico Pin Logic
Active BuzzerPositive (+)GP0Active HIGH
Active BuzzerNegative (-)GNDCommon Ground

2. JavaScript Implementation

Using the asynchronous sleep helper allows for non-blocking timing intervals.

JavaScript (SDK)
import intarva, { Pin, sleep } from 'intarva';

// Pin('GP0') corresponds to the Buzzer signal line
const buzzer = new Pin('GP0');

async function runBuzzer() {
    console.log("Alarm System: Active and monitoring...");
    
    while (true) {
        console.log("ALERT: Buzzer ON");
        buzzer.write(1); // Set pin HIGH
        await sleep(500); // Wait 500ms
        
        console.log("ALERT: Buzzer OFF");
        buzzer.write(0); // Set pin LOW
        await sleep(1500); // Wait 1.5s before next cycle
    }
}

// Start only when simulation engine is ready
intarva.on('ready', runBuzzer);
            

3. Simulation Result

The following video demonstrates the synchronized behavior of the Pico’s GP0 output and the audible feedback from the active buzzer as defined in the logic above.