Alex Glow
Published © GPL3+

Touchless Handwashing Timer / Nightlight

Program a cute little timer that activates when you clap your hands! Perfect for shared bathrooms.

BeginnerProtip30 minutes2,548
Touchless Handwashing Timer / Nightlight

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Code

handwash.js

JavaScript
Paste this into the JavaScript tab in the MakeCode editor, for an easy and quick start.
input.onLoudSound(function () {
    washing = 1
    light.setAll(0x00ff00)
    for (let index = 0; index <= 10; index++) {
        pause(1000)
        light.setPixelColor(index, 0xff8000)
        pause(1000)
        light.setPixelColor(index, 0x000000)
    }
    light.showAnimation(light.rainbowAnimation, 1000)
    music.baDing.play()
    light.setAll(0x000000)
    washing = 0
})
let washing = 0
washing = 0
forever(function () {
    while (washing == 0) {
        if (input.lightLevel() < 50) {
            light.showRing(
            `orange red orange red orange orange red orange red orange`
            )
        } else {
            light.setAll(0x000000)
        }
    }
})

circuitplayground-handwash-timer.uf2

JavaScript
The compiled block-code file: just drag and drop onto your CPX when it shows up as a flash drive on your computer. Also available at https://makecode.com/_7iWH8L0a6Yw4
No preview (download only).

Credits

Alex Glow

Alex Glow

145 projects β€’ 1570 followers
The Hackster team's resident Hardware Nerd. I love robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments