RFID & images - Help with startup image.
in
Integration and Hardware
•
5 months ago
Hello,
I currently have 4 images.
1 that appears when the processing code is run and then 3 others that come when the specific RFID tag is placed on the reader.
What I need some help with is that once a tag is placed on the reader. I want the reader to keep reading the tag, then once the tag has been taken off to go back to the startup image which in my code is called 'stack'.
Here is my code:
- import processing.serial.*;
- Serial myPort;
- String inString;
- String RFID1 = "67005DB143C8"; //Card 1 RFID
- String RFID2 = "67005DC651AD"; //Card 2 RFID
- String RFID3 = "2500AC086AEB"; //Card 3 RFID
- PImage jpg;
- boolean sketchFullScreen() {
- return true;
- }
- void setup() {
- size(1280, 800);
- myPort = new Serial(this, Serial.list()[5], 9600);
- myPort.bufferUntil('\n');
- jpg = loadImage("stack.jpg");
- if (frame != null) {
- frame.setResizable(true);
- }
- }
- void draw() {
- background(255);
- image(jpg, width/1500, height/900);
- if(inString != null){
- fill(150,255);
- }
- }
- void serialEvent (Serial myPort) {
- inString = myPort.readStringUntil('\n');
- if (inString != null) {
- inString = trim(inString); // trim off any whitespace:
- print("RFID = " + inString + " : ");
- if (RFID1.equals(inString) == true){ //checks inString to see if it matches the first RFID
- println("Card 1");
- jpg = loadImage("card1.jpg");
- }
- if (RFID2.equals(inString) == true){ //checks inString to see if it matches the first RFID
- println("Card 2");
- jpg = loadImage("card2.jpg");
- }
- if (RFID3.equals(inString) == true){ //checks inString to see if it matches the first RFID
- println("Card 3");
- jpg = loadImage("card3.jpg");
- }
- }
- }
Does any of you kind people know how I would go about doing this please?
Thanks.
1