obniz Parts Library

Grove_JoyStick

GitHub
Grove_JoyStick
Usable Devices :
obniz_board
Found at :

Grove_JoyStick

X and Y direction with Push Switch Joystick.
It uses the I2C communication.

wired(obniz, {[scl, sda, vcc, gnd, grove]})

connect to the obniz device.
White, yellow, red and black wires correspond to scl, sda, vcc and gnd respectively.

name type required default description
vcc number(obniz Board io) no   Power Supply
gnd number(obniz Board io) no   Power Supply
scl number(obniz Board io) no   scl of I2C
sda number(obniz Board io) no   sda of I2C
i2c object no   obniz i2c object
grove object no   grove interface object if a device has
var obniz = new Obniz.M5StickC("OBNIZ_ID_HERE");
obniz.onconnect = async function() {
  var joystick = obniz.wired("Grove_JoyStick", { grove: obniz.grove0 });
  while(true) {
    var x = await joystick.getXWait()
    var y = await joystick.getYWait()
    console.log(`${x}-${y}`);
    await obniz.wait(1);
  }
}

[await] isPressedWait()

get the button state once.

// JavaScript Examples
var joystick = obniz.wired("Grove_JoyStick", { grove: obniz.grove0 });
var isPressed = await joystick.isPressedWait();
if (isPressed) {
    console.log("Pressed!");
}

[await] getXWait()

[await] getYWait()

get X or Y angle once.

Value range is 0 to 255. Device has individual difference. So minimum and maximum value is different on each joystick.

// JavaScript Examples
var joystick = obniz.wired("Grove_JoyStick", { grove: obniz.grove0 });
while(true) {
  var x = await joystick.getXWait()
  var y = await joystick.getYWait()
  console.log(`${x}-${y}`);
  await obniz.wait(1);
}

Supported from: obniz.js 3.5.0

You will Get in Few Days

Circuit for Starter “obniz Board” is available on Amazon and other online stores.
You can get it at below

Our products and resellers

Forum

Visit our developer’s forum to discuss and discover technologies.

Forum

Contact

Feel free to contact out support and technical team.

Contact us