![]()
YOU LEARN HERE... |
|
EXPERIMENT 1: WASSERSTANDMESSUNG |
|
|
Ergänze deine Anlage und dein Programm mit einem Wasserstand-Alarm. Wenn es zu wenig Wasser hat, wird auf dem Display ein Warnsignal angezeigt oder ein akkustisches Signal ausgelöst. |
MEMO |
|
|
Acceleration generally means the rate of change of velocity, that is, one-dimensional
![]()
where v is the speed.
From the three acceleration components you can calculate pitch and roll angles as shown below. Start the following program and tilt the board sideways or forwards and backwards. In the terminal window, the values of pitch and roll are written out in degrees.
from microbit import * from math import * def getPitch(): a = accelerometer.get_values() pitch = atan2(a[1], -a[2]) return int(degrees(pitch)) def getRoll(): a = accelerometer.get_values() anorm = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]) roll = asin(a[0] / anorm) return int(degrees(roll)) while True: pitch = getPitch() roll = getRoll() print("p: " + str(pitch)) print("r: " + str(roll)) print() sleep(100)