# === Pico 1: MPU6050 + UART TX ===
from machine import Pin, I2C, UART
from time import sleep
import mpu6050
i2c = I2C(0, scl=Pin(1), sda=Pin(0))
mpu = mpu6050.accel(i2c)
uart = UART(0, baudrate=9600, tx=Pin(4), rx=Pin(5)) # RX not used
while True:
ax = mpu.get_values()["AcX"]
ay = mpu.get_values()["AcY"]
az = mpu.get_values()["AcZ"]
# Deteksi jatuh sederhana: threshold percepatan mendadak
total = (ax**2 + ay**2 + az**2)**0.5
status = "JATUH" if total > 30000 else "AMAN"
uart.write(status + "\n")
sleep(1)