Sven Haiges
Published © CC BY

Calliope Noise Sensor

Use the calliope mini to detect a noisy environment. Use the buttons to change the noise level above which calliope mini shows a sad face.

BeginnerShowcase (no instructions)30 minutes2,759
Calliope Noise Sensor

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Schematics

Full program

File missing, please reupload.

Code

Noise Sensor

JavaScript
let level = 0
let mic = 0
input.onButtonPressed(Button.A, () => {
    level += -5
})
input.onButtonPressed(Button.B, () => {
    level += 5
})
basic.forever(() => {
    mic = pins.analogReadPin(AnalogPin.MIC)
    serial.writeNumber(mic)
    serial.writeLine("")
    if (mic > level) {
        basic.setLedColor(Colors.Red)
        basic.showIcon(IconNames.Sad)
        basic.pause(500)
        basic.clearScreen()
    } else {
        basic.setLedColor(Colors.Green)
    }
})
level = pins.analogReadPin(AnalogPin.MIC)
basic.showNumber(level)

Credits

Sven Haiges

Sven Haiges

4 projects • 17 followers

Comments