#!/usr/bin/env python # -*- coding: utf-8 -*- ''' # @Time : 2025/9/24 14:07 # @Author : reenrr # @File : test.py ''' #!/usr/bin/env python # -*- coding: utf-8 -*- ''' # @Time : 2025/6/17 09:26 # @Author : reenrr # @File : vibration_control-test.py ''' import time from periphery import GPIO # GPIO0_B2_d 对应的 Linux GPIO 编号为 10 gpio = GPIO(10, "out") # 设置为输出模式 try: print("开始电平切换 (按 Ctrl+C 停止)...") while True: gpio.write(True) # 输出高电平 print("高电平") time.sleep(10) # 保持 1 秒 gpio.write(False) # 输出低电平 print("低电平") time.sleep(5) except KeyboardInterrupt: print("已手动停止") finally: gpio.write(False) # 程序结束前确保拉低电平 gpio.close()