Skip to content

chrisfejiro/SoundAlarmViaButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 

Repository files navigation

Arduino-Triggered Alarm System using Python

This project connects a button on an Arduino to a Python script that plays a sound alarm (beep) and blinks an LED when the button is pressed. It's a basic example of how to integrate Arduino hardware with Python for simple I/O interactions.


πŸ”§ Features

  • Uses a push-button to trigger an alarm.
  • Plays a beep sound using the Windows winsound module.
  • Blinks an LED (or activates a buzzer) on the Arduino.

πŸ“¦ Requirements

  • Python 3.9 or later (Windows only, due to winsound)
  • Arduino board (e.g., Uno)
  • Button connected to digital pin 2
  • LED or buzzer connected to digital pin 3
  • Standard Firmata firmware uploaded to the Arduino

πŸ›  Installation

  1. Install Python libraries:

    pip install pyfirmata

Upload Firmata firmware to Arduino:

Open Arduino IDE.

Go to File > Examples > Firmata > StandardFirmata.

Upload it to your board.

Circuit Setup:

Button between digital pin 2 and GND (use pull-up/pull-down as needed).

LED/buzzer between digital pin 3 and GND (with resistor if needed).

Run the script:

bash Copy code python alarm.py (Replace alarm.py with your filename.)

πŸ–₯ How It Works The Python script uses pyfirmata to communicate with the Arduino over USB.

When the button is pressed, the script:

Beeps using winsound.Beep().

Blinks an external LED or activates a buzzer connected to the Arduino.

🧠 Notes This script only works on Windows because winsound is a Windows-only module.

Ensure that no other program (like Arduino IDE) is using the COM port while running the script.

You can modify the pin numbers or beep duration to suit your hardware.

πŸ“ Files alarm.py – Main Python script

README.md – This file

πŸ“œ License This project is free to use and modify.

πŸ™Œ Acknowledgments pyFirmata – Python interface for Arduino

About

An Arduino code paired with python to create a sound alarm via a button

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages