måndag 1 juni 2015

Arduino to Unity Project Part 3: Components and soldering



I ordered some new components for my project:

2 x thumbstick joysticks
2 x break out board(for the joysticks)
1 x connecting headers





The thumbstick consist of two potentiometers, one for horizontal movement (X-axis) and one for Vertical(Y-axis). You can also press down on the thumbstick to press a button.

I soldered the thumbstick to the breakout board and then soldered on a 5-pin header to be able to connect cables to the break out board.



Then I connected the thumbstick to the arduino as described here: http://42bots.com/tutorials/arduino-joystick-module-example/



The same link also provided a example sketch to print out the values of the horisontal and vertical potentiometers. The sketch worked fine. I noticed that both potentiometers had a range of 1-1020. For example, pushing the thumbstick all the way forward showed 1020 on the X-axis and 510 on the Y-axis. I wanted to define 8 directions on the thumbstick input so I wrote a sketch that printed a number depending on within which range it was.



The result ended up as this:





1 kommentar:

  1. Muy bueno! gracias por la ayuda, andaba buscando algo asi para el joystick, necesitaab manejar unos servos.

    SvaraRadera