Here is a crude suggested approaches:
from microbit import *
while True:
gesture = accelerometer.current_gesture()
if gesture == "3g":
display.show(accelerometer.get_z())
sleep(1000) # will wait 1s (1000ms) before moving on
else:
display.show("-")
Note I’ve assumed you wanted the vertical (z axis) acceleration displayed (swap z for x or y as appropriate – if you don’t care you could use:
display.show(max(accelerometer.get_x(),accelerometer.get_y(),accelerometer.get_z()))
and it will show the biggest in any of three directions.
An alternative would be something like:
from microbit import *
while True:
gesture = accelerometer.current_gesture()
if gesture == "3g":
value = max(accelerometer.get_values())
display.show(value)
elif gesture == "shake":
display.show("-")
Which I *think* should display – then when it gets a 3g geture display the largest accelerometer value and leave it on the display until you shake the device to reset it.