re-activation for rfid reader

edited January 2014 in Programming Questions

hi question again

I'm trying to read the rfid tag data for linking something

okay now step is going well

once the data of tag is read , then something happen like link() url which should execute once.

(the reader still capturing)

import processing.serial.*;

Serial myPort;  // Create object from Serial class

String dummy;

boolean linkOpened1 = false;
boolean linkOpened2 = false;


void setup()
{
  size(200, 200);
  background(255);

  myPort = new Serial(this, Serial.list()[8], 9600); 

  dummy=" ";
}
void draw()
{


  byte[] inBuffer = new byte[7];
  while (myPort.available () > 0) {
    inBuffer = myPort.readBytes();
    myPort.readBytes(inBuffer);


    if (inBuffer != null) {

      String myString = new String(inBuffer);

      println(myString);

      if (!linkOpened1 && myString.equals("187")) { 

        println("received 187");
        link("http://mj3989.tumblr.com"); 
        linkOpened1 = true;
        linkOpened2 = false;
      }

      if (!linkOpened2 && myString.equals("139")) { 

        println("received 139");
        link ("http://melaniejnewbould.tumblr.com"); 
        linkOpened2 = true;
        linkOpened1 = false;
      }

      //     if(dummy.equals("187") == false) {
      //      linkOpened1 = false; 
      //     }
    }
  }
}

but one small problem is how to reactivate statement

when I try to take tag out of range of reader after calling link()

then get tag inside of range again

Is it possible to repeat calling link() again ?

how to do this any suggestion?

Answers

  • edited January 2014

    or when the data is not readable is it possible to execute something like the println() or boolean?

  • edited January 2014

    As I wrote in the previous thread, re-set the boolean to false after a number of milliseconds (using millis()) is spent.
    Or some other event, like key press or click.

Sign In or Register to comment.