How to stop a programe after 30sec & save them automatically - Raspberry Pi Forums


hello users

doing basic gyroscopic experiments using the raspberry pi , sensehat. since don't have experience programming , such, searched online , found sensehat api https://pythonhosted.org/sense-hat/api/ (which modified somehow code might messy) programme using on python 3 file:

sense_hat import sensehat
sense = sensehat()
sense.clear()
while true:
o = sense.get_gyroscope_raw()
x = o["x"]
x = round(x, 0)
print(" {0}, " .format(x))

problem don't know how stop programme automatically (maybe after 30 sec of running it. know ctrl + c it's manual) correct codes , python shell (after running file) being saved automatically (on desktop) python code it. if you'll don't know above codes do, please tell me codes because i'm stuck.

hope community can me. :lol:

advanced thanks
adleivade12

could not add time.sleep(0.1) @ beginning of while true loop increment value 1 every loop, every ten loops 1 second :?: , if statement check , quit on required time. if want save data write file


raspberrypi



Comments