Posts

Showing posts with the label Arduino

First Sensor – KY-023 Joystick

Image
This little joystick is similar to the ones on many modern game controllers. It slides smoothly in X and Y and clicks a button when pressed. The X and Y axes are connected to potentiometers and form a voltage divider between 0v and 5v with the center rest point theoretically being at the 2.5v point. Reading the joysticks is as simple as polling two analog inputs. The switch connects to ground when depressed, so use a digital input with the Arduino’s built in pullup resistor. Below is the code that I ended up with for reading this sensor. It’s a very basic program that sets up the appropriate pins and then loops forever reading the values from all three pins and displays them via the serial port. I’ll definitely revisit this joystick in some of the future projects as a simple input device that allows for two different analog values and a digital input for triggering. Pros: Simple interface – power, ground, 2x analog, 1x digital Feels smooth and clicks nicely Cons: The values return hit ...