-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.py
31 lines (28 loc) · 1.01 KB
/
all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
# ライブラリのインポート
from time import sleep
from sense_hat import SenseHat
# IMUセンサーのセッティング
sense = SenseHat()
sense.set_imu_config(False, True, False)
while True:
# センサーデータ取得
humidity = sense.get_humidity()
temp = sense.get_temperature()
pressure = sense.get_pressure()
orientation = sense.get_orientation_degrees()
north = sense.get_compass()
gyro_only = sense.get_gyroscope()
accel_only = sense.get_accelerometer()
event = sense.stick.get_events()
print("Humidity: %s %%rH" % humidity)
print("Temperature: %s C" % temp)
print("Pressure: %s Millibars" % pressure)
print("p: {pitch}, r: {roll}, y: {yaw}".format(**orientation))
print("North: %s" % north)
print("p: {pitch}, r: {roll}, y: {yaw}".format(**gyro_only))
print("p: {pitch}, r: {roll}, y: {yaw}".format(**accel_only))
print("The joystick event was " + str(event))
print("-----")
# 2秒間の停止
sleep(2)