Now that we’ve been able to sense the level of water turbidity, we can now count the number of potential animals that pass by to visit the body of water. We’ll do this using the gesture sensor and a 4-digit segment display. When the gesture sensor senses something going past, it will tell the variable Count to increase by one. This way, we’ll be able to count the number of animals!
In the Microbit/Makecode app. Create a new project titled Gesture Sensor.
Then select Advanced > Extensions and search for the “Grove” extension.
Then in your on start code you will want to create a new variable called count. Drag the set [count] block to 0 inside the on start code.
Next we want to create a new variable called display. And place that set [display] to 0 block beneath the set [count] to 0 block.
Next we need a block found under Grove > 4 Digit Display at [P0] and [P14], and place that within the set [display] to block.
Next we will grab the Grove > On Gesture [Right]
And place within it
Variables > Change [count] by 1
Grove > Display show number (count). You will need to drag the round count block from variables. And change the “strip” variable to the display variable.