Video forwarding with Processing - request

Hi guys,
Im new to Arduino+Processing and I have a project for school.
can anyone help me with coding this task-
Im using an infrared sensor with this code on arduino (attached) and I would like to ‘forward’ a playing video (for 2 seconds and back to ‘play’) of mine whenever there’s an obstacle infront of the sensor.

could you help me with the codding of processing? thank you from the bottom of my heart!


#define IR 8

int Obstacle;

void setup() {
  pinMode(IR, INPUT);

void loop() {
  Obstacle = digitalRead(IR);

  if (Obstacle == LOW) {
 else {
   Serial.println("All Clear");


as a first step need to make a Arduino code

-1- that not send 1000 lines per sec as your PC/OS/processing
might get stuck, but sure you might not be able to follow any printed data.

-2- now while test you might use
delay(100); // 10 lines per sec
there could be a complete different approach,
just send one line on CHANGE ( and not need any delay )
that would require to have a memory variable "

int obstacle,obstacleold;
// for check use
if ( obstacleold != obstacle ) Serial.println(obstacle);
obstacleold = obstacle;

-3- there is no use in computer communication to send words, you not
talk to human or a WORD program.
send a “0” or “1”,
did you try


what you see on the Arduino IDE Monitor window.

for the processing code could follow
or a tutorial…

1 Like


I was able to make this work with: (you will have to add library)

And from the Processing examples:


You will have to integrate the code and modify it for your use.