We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Below is the code for servo motor control using joystick but every time I run the program I get the NullPointerException error for the line no. 70 and 71: stickPosX = stick.getX() and stickPosY = stick.getY()
import procontroll.*;
import java.io.*;
ControllIO controll;
ControllDevice device;
ControllStick stick;
ControllStick stick1;
ControllButton button1;
ControllButton button2;
ControllButton button3;
ControllButton button4;
ControllButton button5;
import processing.serial.*;
Serial myPort;
int xIdent = 200;
int yIdent = 201;
float stickPosX = 360;
float stickPosY = 360;
void setup() 
{
  size(720, 720);
  smooth();
  noStroke();
  controll = ControllIO.getInstance(this);
  controll.printDevices();
  device = controll.getDevice("USB Vibration Joystick");
  device.printSticks();
  device.printSliders();
  ControllSlider sliderX = device.getSlider("X-akse");
  ControllSlider sliderY = device.getSlider("Y-akse");
  ControllSlider glidebryterX = device.getSlider("Glidebryter");
  ControllSlider Z_rotasjon = device.getSlider("Z-rotasjon");
  stick = new ControllStick(sliderX, sliderY);
  stick1 = new ControllStick(glidebryterX, Z_rotasjon);
  device.setTolerance(0.005f);
  device.printButtons();
  button1 = device.getButton("Knapp 1");
  button2 = device.getButton("Knapp 0");
  button3 = device.getButton("Knapp 2");
  button4 = device.getButton("Knapp 3");
  button5 = device.getButton("Knapp 4");
  println(Serial.list());
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}
void draw() {
  background( 50 );
      stickPosX = stick.getX();
      stickPosY = stick.getY();
  stickPosX = map(stickPosX, -1, 1, 0, 720);
  stickPosY = map(stickPosY, -1, 1, 0, 720);
  constrain(stickPosX, 0, 720);
  constrain(stickPosY, 0, 720);
  myPort.write(xIdent);
  myPort.write(int(map(stickPosX, 0, 720, 120, 80)));
  myPort.write(yIdent);
  myPort.write(int(map(stickPosY, 0, 720, 90, 30)));
  fill(255, 0, 0);
  ellipse(stickPosX, stickPosY, 33, 33);
}
Answers
https://www.Reddit.com/r/processing/comments/4f31yi/getting_a_nullpointerexception_error_in_processing/