Qing Wei
Published © GPL3+

Simple lamp

A simple lamp with a switch made by Adafruit circuit playgound board.

BeginnerFull instructions provided2 hours385
Simple lamp

Story

Read more

Code

Make it switch

C/C++
The code is from Make it switch tutorial on adafruit website. This code allows me to use a toggle switch to turn on or off the lights of circuit playground board. Beside of its original code, I add the code of music and brightness. Since I am making a simple lamp, I want to make the light bright. I add the jumpup sound just for fun.
pins.A1.setPull(PinPullMode.PullUp)
forever(function () {
    if (pins.A1.digitalRead()) {
        light.showAnimation(light.rainbowAnimation, 500)
        music.jumpUp.play()
        light.setBrightness(185)
    } else {
        light.clear()
    }
})

Credits

Qing Wei
3 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.