Datasheet

Connect Yout on the joystick to pin A1 on your board.
Connect Sel on the joystick to pin A2 on your board.
Remember, Trinket's pins are labeled differently. Check the Trinket Pinouts page (https://adafru.it/AMd) to verify your
wiring.
To use this demo, simply move the joystick around. The mouse will move slowly if you move the joystick a little off
center, and more quickly if you move it as far as it goes. Press down on the joystick to click the mouse. Awesome! Now
let's take a look at the code.
Create the Objects and Variables
First we create the mouse object.
Next, we set x_axis and y_axis to pins A0 and A1 . Then we set select to A2 , set it as input and give it a pullup.
The x and y axis on the joystick act like 2 potentiometers. We'll be using them just like we did in CircuitPython Analog
In (https://adafru.it/Bep). We set pot_min and pot_max to be the minimum and maximum voltage read from the
potentiometers. We assign step = (pot_max - pot_min) / 20.0 to use in a helper function.
CircuitPython HID Mouse Helpers
First we have the get_voltage() helper so we can get the correct readings from the potentiometers. Look familiar? We
learned about it in Analog In (https://adafru.it/Bep).
Second, we have steps(axis) . To use it, you provide it with the axis you're reading. This is where we're going to use
the step variable we assigned earlier. The potentiometer range is 0-3.29. This is a small range. It's even smaller with
© Adafruit Industries https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express Page 161 of 179