lazybug19 / DanceMania_Game

Python and capacitive-touch based navigation game
0 stars 0 forks source link

Reducing code duplication in `dancepad.py` #1

Closed Saphereye closed 5 months ago

Saphereye commented 7 months ago

Can be probably rewritten to


import serial
import pyautogui

arduino = serial.Serial(port='COM15', baudrate=9600)
val=arduino.read().decode().strip()

while (True):
  val = arduino.read().decode().strip()

  if val.isupper(): # New part
    pyautogui.keyDown(val.lower())
  else:
    pyautogui.keyUp(val)

Now can be generalised to all keys

lazybug19 commented 5 months ago

ok sir