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)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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)