Loading...
Logo
Processing Forum
while i m communicating with arduino, i m getting this error

Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PGraphics.text(Unknown Source)
at processing.core.PApplet.text(Unknown Source)
at sketch_counter_1.draw(sketch_counter_1.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)

Replies(1)

This has nothing to do with arduino. It's a NullPointerException for a text String.

This will produce the same error:
Copy code
  1. String txt;

  2. void setup() {
  3.   text(txt, 0, 0);
  4. }
The problem is that your text string is null. You should fill it with some text before you display it. Or test if it is null.
Copy code
  1. String txt;
  2.  
  3. void setup() {
  4.   // option 1
  5.   if (txt != null) text(txt, 0, 0);
  6.  
  7.   //option 2
  8.   txt = "Some text";
  9.   text(txt, 0, 0);
  10. }