Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Serial Library: Connect and disconnect

$
0
0
Just a guess as I don't have such devices. Create 2 methods:
  1. createConnection() .
  2. closeConnection() .

Within closeConnection() , make myPort = null; as also a flag to indicate it's not active anymore:

    import processing.serial.*;
    Serial myPort;
    
    void draw() {
      if (myPort == null)  createConnection();
    }
    
    void createConnection() {
      myPort = new Serial(this, Serial.list()[0], 9600);
    }
    
    void closeConnection() {
      myPort.stop();
      myPort = null;
    }
    

Viewing all articles
Browse latest Browse all 1768

Trending Articles