Unfortunately it's not as easy to make the air pressure sensor values change as holding your thumb on the sensor or breathing on it. But I've come up with a neat and cheap way that you can use in the classroom with your kids.
You will need:
- A two litre plastic bottle (circular in cross section)
- A mobile phone top up battery
- A USB-A to Micro USB-b lead
- A pair of scissors
- Sticky tape, any kind
https://www.youtube.com/watch?v=CHUukiKF3ew
Here is the code:
Code: Select all
from astro_pi import AstroPi
ap = AstroPi()
ap.clear()
ratio = 255 / 100.0
while True:
pressure = ap.get_pressure()
pressure = round(pressure, 1) - 1000
blue = int(ratio * pressure)
if blue > 255:
blue = 255
ap.clear((0, 0, blue))