Turn a led on and off with a physical button, mapping the reading from 0 to 100.
This tutorial is part of the Nairda learning path. You can build it step by step inside the app, which checks every block you place before letting you move on.
The steps
- We add a While loop, which repeats forever.
- We declare a led on pin 13.
- We declare a digital input called button on pin 2.
- We create a number variable called reading.
- Inside the loop we put a delay of 100 milliseconds.
- Behind it we set reading to a Map block.
- What we map is the button, which only gives 0 or 1.
- And it comes out between 0 and 100, which is the led brightness.
- Behind it we put the led and give it the variable reading.
When you finish, the app takes you straight to the next tutorial in the path.