Coding your Circuit
Duration: 15 minutes
Blocks
lights.setLevel(AnalogPin.A0, 100)
Step 1: Setting up your loop
- Open MakeCode in your browser.
- From CONTROL, drag a forever loop into your workspace.
Step 2: Coding your pin connection
From LIGHTS, drag a set A0 to 100 block out and place it into your forever loop.
loops.forever(function () {
lights.setLevel(AnalogPin.A0, 100)
})
Build the Block…
Change the pin value of the set block from A0
to A1
.
lights.setLevel(AnalogPin.A1, 100)
So, now we have:
loops.forever(function () {
lights.setLevel(AnalogPin.A1, 100)
})
Finished!
Good work! By setting the value to a high number such as 100, it means that the current of power will be strong enough to light up a LED. Using your paper fold switch, try to turn your LED on and off. Does it work?