GND에 빨간선이 연결되어있고
스위치의 반대편은 GPIO로 연결되어 있는데
GPIO에 pull up이 있어서 인지 스위치를 누르면 ground로 인식이 된다.
(아래 코드에서 4번째 라인 not을 지웠다가 파일 바꾼다고 dog 고생을...)
while True:
# Check each pin
for key_pin in key_pin_array:
if not key_pin.value: # Is it grounded?
i = key_pin_array.index(key_pin)
print("Pin #{} is grounded.".format(i))
# Turn on the red LED
led.value = True
while not key_pin.value:
pass # Wait for it to be ungrounded!
# "Type" the Keycode or string
key = keys_pressed[i] # Get the corresponding Keycode or string
if isinstance(key, str): # If it's a string...
keyboard_layout.write(key) # ...Print the string
else: # If it's not a string...
keyboard.press(control_key, key) # "Press"...
keyboard.release_all() # ..."Release"!
# Turn off the red LED
led.value = False
time.sleep(0.01)
아무튼.. 원래 의도는 3V 전원에서 330옴 통해서 전류 제한해서 gpio로 3.3V가 들어가게 하는거였는데
멀 잘못했네.. 멀티메터로는 정상적으로 3.3V 나오던데 ㅠㅠ
[링크 : https://circuitpython.readthedocs.io/projects/hid/en/latest/api.html]
+
'embeded > rpi pico' 카테고리의 다른 글
rpi pico pwm channel (0) | 2021.08.02 |
---|---|
rpi pico c (0) | 2021.07.07 |
rpi pico, circuitpython, USB HID (0) | 2021.06.28 |
rpi pico pinout (0) | 2021.06.28 |
rpi pico USB OTG를 이용한 오실로스코프 (0) | 2021.06.27 |