mpu/main.go

44 lines
690 B
Go
Raw Normal View History

2024-07-24 11:29:00 +00:00
package main
import (
"log"
"github.com/CGSG-2021-AE4/mpu-test/mpu6050"
)
func main() {
log.Println("CGSG forever!!!")
if err := mainE(); err != nil {
log.Println("MAIN finished with error:", err.Error())
}
log.Println("END")
}
func mainE() error {
log.Println("OPEN")
mpu, err := mpu6050.Open()
if err != nil {
return err
}
2024-07-24 12:40:35 +00:00
log.Println("LOOP")
log.Println("ACCEL")
for {
temp, err := mpu.GetTemp()
if err != nil {
return err
}
log.Println("Temp:", temp)
accel, err := mpu.GetAccel(false)
if err != nil {
return err
}
log.Println("Accel:", accel)
gyro, err := mpu.GetGyro()
if err != nil {
return err
}
log.Println("Gyro:", gyro)
2024-07-24 11:29:00 +00:00
}
}