YARPF

Raspberry Pi Logo YetAnotherRaspberryPiFanpage

Siren Sound

This will produce a siren sound.

Plan

wiring plan

Board

bread board

Code

#!/usr/bin/env python

import time
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)

# channel=12 frequency=700Hz
p = GPIO.PWM(12, 700)
p.start(50)

try:
    while True:

		# Frequency is set from 300 Mhz to 700 Mhz,
		# 5 steps, with a pause of 0.002 seconds in between.
		# PLEASE play with those values ;)

        for freq in range(300, 700, 5):
            p.ChangeFrequency(freq)
            time.sleep(0.002)

        for freq in range(700, 300, -5):
            p.ChangeFrequency(freq)
            time.sleep(0.002)

except KeyboardInterrupt:
    pass

p.stop()

GPIO.cleanup()

Video

Please raise your volume =;)

Download

Comments ?

blog comments powered by Disqus