To
be able to use the buttons, joysticks and triggers of the xbox
controler into processing easily, we need to use a librairy. There is
a special librairy dedicated to jospads and controllers, it is called
ProControll.
More
info about Procontroll library:
http://creativecomputing.cc/p5libs/procontroll/
With
a controller like the Xbox 360 controller, acquiring a button change
is quite easy. However, acquiring and using the value, for one or
several axis, of the joystick, is a bit more difficult.
Actually,
for the josticks, the value returned by the controller is a large
floating decimal value.
This
one needs to be converted into a value that we can directly use and
send to the Arduino.
Also,
as the joytick is not a perfect circle, and as it can be very
sensitive, a function to control the tolerance needs to be used.
I
have looked over internet, and I found this video on youtube:
The
person described how to control a motor with a Xbox controller. There
is below the video the description and also the code that the person
used. I thank a lot Mr Mspinksosu because his video and code helped
me a lot.
I
adapted the code to fit in my project. The main changes are that I
simplified the code a lot, I adapted the Processing side to get the
value of the X and Y axis of the right joystick, and on the Arduino
side, I removed the interuptions and I changed a bit the code in
order to drive the servo with the servo.h library.
Hi
RépondreSupprimerCould you please be so kind and share your adapted library on your blog for the benefit of others looking to start out with similar projects?
Best Regards
Michael Birnbaum
I too could benefit from your adapted library (you would be cited in anything I develop with your code, too).
RépondreSupprimer