Read distance with an ultrasonic sensor and draw it on the dashboard chart.
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 create a number variable called reading.
- We declare an ultrasonic called ultra, trigger on 9 and echo on 10.
- Inside the loop we set reading to the distance the sensor measures.
- On the dashboard we draw a chart and give it the variable reading.
When you finish, the app takes you straight to the next tutorial in the path.