Hall effect sensor linking to a Processing video

Hi, I just wanted to know how to link up my Arduino with Processing (that's playing a video).

My project is consists of rollers with magnets on the side, so the Arduino can link to a video playing in Processing (also hopefully stop playing when the rollers aren't moving). I had helped with the Arduino side of things but unfortunately my friend is very busy and needs to carry on with his own projects. If anyone could help me out / refer me to someone who I can pay for setting up like this that would be great!

So far:

I have managed to hook up a Hall effect switch to the Arduino and an LED, the hall effect switch detects output from magnets and switches on and off depending on the side of the magnet (North pole / South pole).

Code for Arduino:

int potPin = 0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
int incomingData; // To hold value of data coming through COM port

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.print("hello"); // prints hello with ending line break
}

void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
//if (Serial.available() > 0){
// Read the value and store in incomingData
incomingData = val;
Serial.println(incomingData);
//}

// If the value of the data is greater than 0 then turn on LED
if (incomingData > 0){
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}

Also I have managed to make a video play in Processing, here is the code:

import processing.video.*;
Movie myMovie;

void setup() {
size(600, 600);
frameRate(25);
myMovie = new Movie(this, "wallride.mov");
myMovie.speed(1.0);
myMovie.loop();
}

void draw() {
if(myMovie.available()) {
myMovie.read();
}
image(myMovie, 0, 0);
}

I have managed to hook up a Hall effect switch to the Arduino and an LED, the hall effect switch detects output from magnets and switches on and off depending on the side of the magnet (North pole / South pole).

int potPin = 0; // select the input pin for the potentiometer

Do you have a hall effect sensor or a potentiometer?

int val = 0;       // variable to store the value coming from the sensor
int incomingData;  // To hold value of data coming through COM port

But, you aren't reading from the serial port, so the comment is wrong. Also, these variables are referenced only in the loop() function, so they should be local variables, not global variables.

Serial.print("hello"); // prints hello with ending line break

No, it doesn't. Look at the documentation for Serial::print() and Serial.println().

Also, note that comments are useful when they describe what the program is going to do, not when they state the obvious. Anyone can look at that code and figure out, with a minimum of imagination, that the code prints hello.

You need to write something to the serial port that will be read by Processing.

Then, in the Processing sketch, you need to override the serialEvent() function. There is an implementation of the serialEvent() method provided, but it doesn't do anything. You need to replace it with one that does something. The control of the movie should be based on whatever is read from the serial port. And, of course, your Processing sketch needs to connect to the serial port.

There are plenty of examples in the Processing download that deal with the serial port. You should be able to adapt one of them to stop/start/play a movie.

Hey, I have a hall effect sensor.

Unfortunately I am still very new to the Arduino world and copied the code from a tutorial.

Thank you very much for advice and such a quick reply. I've had some problems with the Processing side of things, finding it very difficult to even play a HD movie file.

Anyway, thanks :).