-
• #2
Looks to me like that's an analog joystick, so you need to read analog values. You also don't need the pin modes that you had:
var BTN = {Y: A0, X: A1, SELECT: B10}; pinMode(BTN.SELECT, "input_pullup"); setInterval(function() { yValue = analogRead(BTN.Y); xValue = analogRead(BTN.X); selectValue = !digitalRead(BTN.SELECT); console.log(xValue, yValue, selectValue); }, 500);
Something like the above should print some values between 0 and 1, and you should be able to figure out when the joystick is over one side by looking at those values (eg less than 0.2 or greater than 0.8 maybe).
Also one thing to watch out for is I'd really avoid
while(true)
in JavaScript because JS likes to execute small functions that execute quickly in order to be able to multi-task. I changed it for some code that checks every 500ms (twice a second) -
• #3
GREAT, IT WORKS!
THANK YOU SO MUCH!
:-)
Hi everyone,
I would like to use this Joystick: https://www.adafruit.com/product/512
with the Espruino WiFi (2v02), it currently works on Feather M4 Express (CircuitPython):
In JavaScript I'm doing tests, Y and X both are recognized at '50 %' (yes UP and LEFT, no DOWN and RIGHT) ...
What do you think I can solve?
THANK YOU