processing arduino via bluetooth
in
Integration and Hardware
•
1 month ago
hello
i want to send variables from processing to arduino via bluetooth.
if i use the port 10 i will get a error message.
if i connect via usb and a other port, the script works.
the processing code
- // import the processing serial library
- import processing.serial.*;
- // and declare an object for our serial port
- Serial port;
- void setup() {
- // Get the name of the first serial port
- // where we assume the Arduino is connected
- String portName = Serial.list()[0];
- // initialize our serial object with this port
- // and the baud rate of 9600
- port = new Serial(this, "COM10", 9600);
- }
- void draw() {
- // Szenedauer, wie lange soll die Kamera Fotos machen.
- int szh = 1;
- int szm = 10;
- int szs = 00;
- // Belichtung, wie lange soll die Belichtungsdauer sein
- int bzm = 1;
- int bzs = 10;
- // Interval, wie lange dauert es zwischen zwei Fotos.
- int izm = 00;
- int izs = 5;
- // load up all the values into a byte array
- // then send the full byte array out over serial
- // NOTE: This only works for values from 0-255
- byte out[] = new byte[7];
- out[0] = byte(szh);
- out[1] = byte(szm);
- out[2] = byte(szs);
- out[3] = byte(bzm);
- out[4] = byte(bzs);
- out[5] = byte(izm);
- out[6] = byte(izm);
- port.write(out);}
The error message
at java.lang.Thread.run(Thread.java:662)java.lang.NullPointerExceptionat processing.serial.Serial.write(Unknown Source)at multivaraiter_string_processing_eeprom.draw(multivaraiter_string_processing_eeprom.java:58)at processing.core.PApplet.handleDraw(PApplet.java:2270)at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:243)at processing.core.PApplet.run(PApplet.java:2141)at java.lang.Thread.run(Thread.java:662)
1