This script generates 3 PWM on pins 23, 24, and 25 of raspberry GPIO, coming from the values of x, y and z accelerometers from a wiimote.
- Raspberry
- bluetooth dongle
- wiimote
This code uses linux bluetooth module and pi-blaster, they should be installed as specified here before running the program. The installation script runs these installations for you.
sudo apt-get install --no-install-recommends bluetooth
If it's working sudo service bluetooth status
should return bluetooth is running
.
sudo apt-get install python-cwiid
git clone https://github.com/sarfata/pi-blaster.git
cd pi-blaster
sudo apt-get install autoconf
./autogen.sh
./configure
make
sudo make install
ln -sfv pi-blaster /usr/bin/pi-blaster
Then run in a separate console pi-blaster sudo pi-blaster
python wiimote-pwm.py
So... this is mostly just shell, so I made a script. Run:
chmod +x install.sh
./install.sh
To detect wiimote on boot and start generating pwm run the following command:
sudo chmod +x onBoot.sh; echo 'bash ~/wiimote-pwm/onBoot.sh' >> ~/.bashrc
This code is licensed under GPLv3.