[Serial Problem] Conditions not working even thought the values match!

edited May 2015 in Arduino

What I am trying to do is read some IR signals.

The code in Arduino is:

 /*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */


 #include <IRremote.h>


 int RECV_PIN = 7;

 IRrecv irrecv(RECV_PIN);

 decode_results results;


 void setup() {

    Serial.begin(9600);

    irrecv.enableIRIn(); // Start the receiver  
}


void loop() {

  if (irrecv.decode(&results)) {

    Serial.println(results.value);

    irrecv.resume(); // Receive the next value

  }

  delay(100);

}

It reads the IR signals, and suppose, Now I want to get this at Processing and want to open a webpage for that.

 // Example by Tom Igoe

 import processing.serial.*;

 Serial myPort;    // The serial port

 String inString;  // Input string from serial port

 int lf = 10;      // ASCII linefeed


 void setup() {

    size(400,200);

    // List all the available serial ports:

    println(Serial.list());

    // Open the port you are using at the rate you want:hat 

    myPort = new Serial(this, "COM9", 9600);

    myPort.bufferUntil(lf);

 }

 void draw() {

   background(0);

   text("received: " + inString, 10,50);


 }

 void serialEvent(Serial p) {

   inString = p.readString();


   if(inString.equals("544993039")){

    String[] params = { "start www.google.com" };

    open(params);


   }
 }

`

But however even though the signal of that value is caught in the receiver, but the codes do not get executed! :/

I am 100% sure that the signal reaches the receiver as Arduino seems to do what I want it to do when I send signals, for example when I use this code: if(results.value == 544993039) { digitalWrite(8, HIGH); }

Anything connected to pin 8 seems to work just fine.

but in Processing:

if(inString.equals("544993039")){

        String[] params = { "start www.google.com" };

        open(params);


       }

Nothing seems to happen. Can anybody help me please?

Answers

Sign In or Register to comment.