Author Topic: Accelerometer to WASD  (Read 1231 times)

0 Members and 1 Guest are viewing this topic.

Offline moonquasarTopic starter

  • Contributor
  • Posts: 12
  • Country: us
Accelerometer to WASD
« on: August 14, 2016, 04:17:50 am »
Here is a small program I made to play my favorite Quake3 Arena mod -- Urban Terror.
This is not my original idea. I saw someone else do it on youtube.

The dev board is kl46z. It has an accelerometer already on it. The board is placed on a wobble board to act as a foot driven joystick. Urban Terror has no analog support, therefore movement must be sent as key presses. The hardware button levels the device so that it can be operated at an angle.
It works pretty well. Would be nice to have a return spring so that the board settles to zero when I take my feet off.
You can see in the code, I tried to reference the Z axis for twisting the board. It took me a lot of noodling before I discovered that the axis which is aligned with gravity is blind to rotation. There is likely a way to use the magnetometer in a sensor fusion arrangement but I have not gotten that far.

http://pastebin.com/9ec1e6C1

Constructive criticism welcome.
« Last Edit: August 14, 2016, 04:19:32 am by moonquasar »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf