touch phat pimoroniというタッチセンサのプログラムを実行したとき下記のようなエラーがでてしまいます。これらを修正するにはどうすればいいのでしょうか。
Traceback (most recent call last):
File "/home/pi/touch sensor.py", line 3, in <module>
import touchphat
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import
module = self._original_import(*args, **kw)
File "/usr/lib/python3/dist-packages/touchphat/init.py", line 13, in <module>
dh = cap1xxx.Cap1166(i2c_addr=0x2c)
File "/usr/lib/python3/dist-packages/cap1xxx.py", line 283, in init
self.product_id = self._get_product_id()
File "/usr/lib/python3/dist-packages/cap1xxx.py", line 469, in _get_product_id
return self._read_byte(R_PRODUCT_ID)
File "/usr/lib/python3/dist-packages/cap1xxx.py", line 494, in _read_byte
return self.i2c.read_byte_data(self.i2c_addr, register)
OSError: [Errno 121] Remote I/O error
Python
1import sys 2import time 3import touchphat 4 5stopped = True 6runtime = 0 7 8@touchphat.on_touch("Enter") 9def start_stop(): 10 global start 11 global stopped 12 global runtime 13 if stopped: 14 start = time.time() 15 stopped = False 16 else: 17 stopped = True 18 runtime += (time.time() - start) 19 20@touchphat.on_touch("Back") 21def reset(): 22 global runtime 23 runtime = 0 24 25blanks = " " * 25 + "\r" 26 27try: 28 while True: 29 if stopped and runtime > 0: 30 sys.stdout.write(blanks) 31 sys.stdout.write("Timer stopped: %i seconds\r" % runtime) 32 sys.stdout.flush() 33 elif stopped: 34 sys.stdout.write(blanks) 35 sys.stdout.write("Touch enter to start!\r") 36 sys.stdout.flush() 37 else: 38 sys.stdout.write(blanks) 39 sys.stdout.write("Timer running: %i seconds\r" % (runtime + (time.time() - start))) 40 sys.stdout.flush() 41 time.sleep(0.1) 42except KeyboardInterrupt(): 43 sys.exit()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/09/26 05:46
2020/09/26 06:12