Hi guys,
I am pretty new to Processing and Arduino so an help would be greatly appreciated.
I have set up an RFID sensor that is being read through my Arduino and I want to play a video through processing, when the RFID is scanned. I can get the video operating through Processing but I need some help on getting the RFID to trigger the video.
Here is my Arduino code
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN         9          // Configurable, see typical pin layout above
#define SS_PIN          10         // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance
int test1=4;
int test2=5;
int test3=6;
int test4=7;
void setup() {
   Serial.begin(9600);		// Initialize serial communications with the PC
   while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
   SPI.begin();			// Init SPI bus
   mfrc522.PCD_Init();		// Init MFRC522
   delay(4);				// Optional delay. Some board do need more time after init to be ready, see Readme
   mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
   Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
 
 Serial.print(test1); // Send the first Value
 Serial.print(','); // Send a delimiter
 Serial.print(test2); // Send the first Value
 Serial.print(','); // Send a delimiter
 Serial.print(test3); // Send the first Value
 Serial.print(','); // Send a delimiter
 Serial.print(test4); // Send the first Value
 Serial.print(','); // Send a delimiter
 Serial.println(); // Send a carriage-return //// all of those serial prints are trevors code, sending values to processing
 
   // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
   if ( ! mfrc522.PICC_IsNewCardPresent()) {
   	return;
   }
   // Select one of the cards
   if ( ! mfrc522.PICC_ReadCardSerial()) {
   	return;
   }
   // Dump debug info about the card; PICC_HaltA() is automatically called
   mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
****//// end of code ////
and here is my processing code:
import processing.serial.*;  // Import the Processing Serial Library for communicating with arduino
import processing.video.*;
Movie video;
Serial myPort;               // The used Serial Port
int test1;
int test2;
int test3;
int test4;
 void setup()
{
  
    println(Serial.list()); // Prints the list of serial available devices (Arduino should be on top of the list)
  myPort = new Serial(this, Serial.list()[2], 9600); // Open a new port and connect with Arduino at 9600 baud
  
  size(2000,2000);
  video = new Movie(this, "TheStoryofMicrofibers.mp4");
  
}
void movieEvent (Movie video){
  video.read();
}
void draw()
{
  image(video, 0, 0);
  print(test1);
  print(test2);
  print(test4);
  print(test3);
}
void serialEvent(Serial myPort) // Is called everytime there is new data to read
{
  if (myPort.available() > 0)
  {
    String completeString = myPort.readStringUntil(10); // Read the Serial port until there is a linefeed/carriage return
    if (completeString != null) // If there is valid data insode the String
    {
      trim(completeString); // Remove whitespace characters at the beginning and end of the string
      String seperateValues[] = split(completeString, ","); // Split the string everytime a delimiter is received
      test1 = int(seperateValues[0]);
      test2 = int(seperateValues[1]);
      test3 = int(seperateValues[2]);
      test4 = int(seperateValues[3]);
    }
  }
}
Any help would be great!