Adaniel132
Published

Operation Lamp

My project is a bright lamp that can act as a nightlight or a simple desk lamp.

BeginnerShowcase (no instructions)76
Operation Lamp

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Tape, Electrical
Tape, Electrical
Cardboard box
printer paper

Story

Read more

Code

Operation Lamp

JavaScript
By flipping the switch on, the lamp is supposed to power on. But, the light is not supposed to show until you turn the potentiometer to turn up the brightness of the lamp.
let pot_value = 0
pins.A1.setPull(PinPullMode.PullUp)
light.setBrightness(255)
forever(function () {
    if (!(pins.A1.digitalRead())) {
        pot_value = pins.A2.analogRead()
        light.graph(pot_value, 1023)
    } else {
        light.clear()
    }
})

Credits

Adaniel132
3 projects • 0 followers

Comments