编译安装wiringOP1234git clone https://github.com/orangepi-xunlong/wiringOPcd wiringOP./build clean./build 测试读取全部引脚: 1gpio readall 在python中使用123456>>> os.system("gpio read 2")10>>> os.system("gpio read 2")00 一些其他语法设置模式: 1gpio mode 2 in 控制输出: 1gpio write 2 0 废话结束当然了做这个的目的是当GPIO引脚为低电平时下载保存esp32-cam拍摄的照片 12345678910111213141516171819import osimport timeimport urllib.requesti=1os.system("gpio mode 2 in")while True and os.popen("gpio read 2").read().splitlines()[0]=='0': print ("starting") time.sleep(0.3)while True: if os.popen("gpio read 2").read().splitlines()[0]=='0': print(time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime())) print(i) urllib.request.urlretrieve("http://192.168.1.109/capture?_cb=1664116597682","cam/%s.jpg" % i) #camera.capture('/home/pi/Desktop/cam_3D/cam_3D/image%s.jpg' % i) urllib.request.urlretrieve("http://192.168.1.109/control?var=framesize&val=10","Resolution") i=i+1 time.sleep(3) time.sleep(0.3) print("waiting")