Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created December 2, 2016 20:52
Show Gist options
  • Save lvidarte/52b77c64f2055a88bb4d343a6dc67081 to your computer and use it in GitHub Desktop.
Save lvidarte/52b77c64f2055a88bb4d343a6dc67081 to your computer and use it in GitHub Desktop.
Wii test
import cwiid
import time
wm = cwiid.Wiimote()
wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC
buttons = {
cwiid.BTN_1: 'button 1',
cwiid.BTN_2: 'button 2',
cwiid.BTN_A: 'button A',
cwiid.BTN_B: 'button B',
cwiid.BTN_LEFT: 'button left',
cwiid.BTN_RIGHT: 'button right',
cwiid.BTN_UP: 'button up',
cwiid.BTN_DOWN: 'button down',
}
def counter():
for i in range(16):
wm.led = i
time.sleep(0.5)
def listen_accelerometer():
while True:
print wm.state['acc']
time.sleep(0.3)
def listen_buttons():
while True:
for button in buttons.keys():
if wm.state['buttons'] == button:
print buttons[button] + ' pressed - code: ' + str(button)
time.sleep(0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment