Nathan Pluskota
Created September 23, 2021 © GPL3+

Rage-o-Meter

A noise detector that sets off an alarm if it counts up 10 noises over a certain threshold or it detects an extremely loud noise.

BeginnerShowcase (no instructions)2 hours12
Rage-o-Meter

Things used in this project

Hardware components

Circuit Playground Bluefruit
Adafruit Circuit Playground Bluefruit
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1

Hand tools and fabrication machines

x-acto blade
Tape, Painters Tape
Tape, Painters Tape

Story

Read more

Custom parts and enclosures

Functionality Video

Housing

Ticker Finally Working

Creating the Housing

Testing Position and Thresholds

Code

CircuitPython - Circuit Playground Bluefruit

Python
import time
from adafruit_circuitplayground.bluefruit import cpb

counter = 0
timer = 0

var = False


def OnOff():
    global var
    global counter
    if cpb.button_a:
        var = not var
        time.sleep(0.05)
        if(counter > 0):
            print("beans")
            
            for i in range(counter):
                cpb.pixels[i] = (0, 0, 0)
                
            counter = 0
        time.sleep(0.05)
    


def LoudNoiseCounter():

    if cpb.sound_level >= 400:
        global counter
        counter += 1
        for i in range(counter):
                cpb.pixels[i] = (255, 0, 0)
                cpb.pixels.show()



def Blink():
    global timer
    global counter
    if cpb.sound_level >= 1000 or counter >= 10:

        while timer < 5:
            cpb.pixels.brightness = 255
            cpb.pixels.fill((255, 0, 0))
            cpb.start_tone(10000)

            time.sleep(0.1)
            cpb.pixels.fill((0, 0, 0))
            cpb.stop_tone()
            cpb.start_tone(12000)

            time.sleep(0.1)
            cpb.stop_tone()
            timer += 0.2
        timer = 0
        if counter >= 10:
            counter = 0
            


while True:
    OnOff()
    print(var)
    if var:
        print(cpb.sound_level)
        print(counter)
        LoudNoiseCounter()
        Blink()
        OnOff()
        time.sleep(0.1)
    time.sleep(0.02)

Credits

Nathan Pluskota
4 projects • 0 followers

Comments