2 Replies - 349 Views - Last Post: 09 July 2013 - 05:59 AM Rate Topic: -----

#1 toasterburn  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 32
  • Joined: 08-March 10

Using Processing to Open Program

Posted 06 July 2013 - 07:10 PM

I am very new to using Processing (and Arduino's for that matter), so I'm not sure what I'm doing wrong; I'm hoping someone here can help.

I have an Arduino scripted to output a "1" to a serial port when a push-button is pressed (and I have confirmed that this works by using a terminal to read traffic on the port). I wrote a Processing script to listen for traffic on the port, and I want it to open and run a Perl script if it finds anything other than a 0.

I know the Processing script is reading the traffic; but when I press the button on the Arduino the script print's "49" (why 49 and not 1 I don't know) and it doesn't open my perl script. It also seems to slow my computer down until I stop the script. Any ideas?

Here is my Script:

import processing.serial.*;


// The serial port:
Serial myPort;       

void setup() {
  // List all the available serial ports
  println(Serial.list());
  // Open the port you are using (COM3) at the rate you want:
  myPort = new Serial(this, Serial.list()[1], 9600);
}

void draw() {
  while (myPort.available() > 0) {
    int inByte = myPort.read();
    println(inByte);

    if (inByte != 0) {
        String file_name = "C:/scripts/test.pl";
        open(file_name);
        }
    }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Using Processing to Open Program

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1371
  • View blog
  • Posts: 4,754
  • Joined: 19-February 09

Re: Using Processing to Open Program

Posted 08 July 2013 - 04:21 PM

The number 49 is the ASCII value for the symbol/character 1.

If you say that you want the value to be considered a character it should be ok.

16    char inByte = myPort.read();


Was This Post Helpful? 0
  • +
  • -

#3 toasterburn  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 32
  • Joined: 08-March 10

Re: Using Processing to Open Program

Posted 09 July 2013 - 05:59 AM

View Post#define, on 08 July 2013 - 04:21 PM, said:

The number 49 is the ASCII value for the symbol/character 1.

If you say that you want the value to be considered a character it should be ok.

16    char inByte = myPort.read();



Ah, that makes sense. I'll try this when I get home. Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1