Dominic Lincourt
Published

Scream Activated Nightlight

Does your child suffer from terrifying nightmares? Well now your child can sleep tight knowing safety is only a scream away.

BeginnerShowcase (no instructions)1 hour245
Scream Activated Nightlight

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Toggle Switch, (On)-Off-(On)
Toggle Switch, (On)-Off-(On)
Used to arm and turn off nightlight.
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
Used to set nightlight's brightness.
×1
Alligator Clips
Alligator Clips
×1
Battery, 3.7 V
Battery, 3.7 V
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

schematic_closeUp.jpg

drawn_schematic.jpg

Code

Scream Activated Nighlight.js

JavaScript
let pot_value = 0
pins.A1.setPull(PinPullMode.PullUp)
forever(function () {
    pot_value = pins.A3.analogRead()
    light.setBrightness(pot_value / 6)
})
forever(function () {
    if (!(pins.A1.digitalRead())) {
        if (input.soundLevel() >= 175) {
            light.setAll(0xffffff)
        }
    } else {
        light.clear()
    }
})

circuitplayground-nightLight_175.uf2

JavaScript
No preview (download only).

Credits

Dominic Lincourt
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.