Python with Wiimote using pywiiuse module
Solution 1
I updated the pywiiuse wrapper. It didn't seem to be made for the latest version of wiiuse (0.12 at the time of this answer), since much of it just wouldn't work in the current iteration.
I've got the package and some example scripts posted here: http://code.google.com/p/pywiiuse/downloads/list
You should also just be able to do
easy_install wiiuse
Since I've also hosted it on pypi.
Solution 2
I've been working with wiimotelib for .NET and it is pretty stable. And contains also wii remote extensions like nunchcuk and other.
Solution 3
For those still looking, I found and documented a simple easy way of pairing with the Wii Remote with python using the lightblue library. I tested it on OS X, but it should work cross platform (ie. on Linux)
Here's my writeup: http://smus.com/prototyping-wii-remote-python/
Solution 4
I know your class is over by now, but for anyone else looking, cwiid is really nice. Installed in Ubuntu like so:
apt-get install libcwiimote-dev python-cwiid
Or get the latest from github.
Reading wiimote sensors (like pitch from accelerometer) is super easy:
import cwiid
print 'place wiimote in discoverable mode (press 1 and 2)...'
wiimote = cwiid.Wiimote()
wiimote.rpt_mode = cwiid.RPT_ACC
#wiimote.state dict now has an acc key with a three-element tuple
print 'pitch: %d' % (wiimote.state['acc'][cwiid.Y])
Admin
Updated on July 15, 2022Comments
-
Admin almost 2 years
After seeing the abilities and hackibility of wiimotes I really want to use it in my 'Intro to programming' final. Everyone must make a python program and present it to the class.
I want to make a game with pygame incorporating a wiimote. I found pywiiuse which is a very basic wrapper for the wiiuse library using c types.
I can NOT get anything beyond LEDs and vibrating to work. Buttons, IR, motion sensing, nothing. I've tried different versions of wiiuse, pywiiuse, even python. I can't even get the examples that came with it to run. Here's the code I made as a simple test. I copied some of the example C++ code.
from pywiiuse import * from time import sleep #Init wiimotes = wiiuse_init() #Find and start the wiimote found = wiiuse_find(wiimotes,1,5) #Make the variable wiimote to the first wiimote init() found wiimote = wiimotes.contents #Set Leds wiiuse_set_leds(wiimote,WIIMOTE_LED_1) #Rumble for 1 second wiiuse_rumble(wiimote,1) sleep(1) wiiuse_rumble(wiimote,0) #Turn motion sensing on(supposedly) wiiuse_motion_sensing(wiimote,1) while 1: #Poll the wiimotes to get the status like pitch or roll if(wiiuse_poll(wiimote,1)): print 'EVENT'
And here's the output when I run it.
wiiuse version 0.9 wiiuse api version 8 [INFO] Found wiimote [assigned wiimote id 1]. EVENT EVENT Traceback (most recent call last): File "C:\Documents and Settings\Nick\Desktop\wiimotetext.py", line 26, in <mod ule> if(wiiuse_poll(wiimote,1)): WindowsError: exception: access violation reading 0x00000004
It seems each time I run it, it prints out EVENT 2-5 times until the trace back. I have no clue what to do at this point, I've been trying for the past two days to get it working.
Thanks!