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!

Arduino:

#define IR 8

int Obstacle;

void setup() {
  pinMode(IR, INPUT);
  Serial.begin(9600);
}

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

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

  }
  delay(0);
}

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

Serial.println(Obstacle);

what you see on the Arduino IDE Monitor window.


for the processing code could follow
https://processing.org/reference/libraries/serial/serialEvent_.html
or a tutorial…
http://kll.engineering-news.org/kllfusion01/articles.php?article_id=92#example3

1 Like

Hello,

I was able to make this work with:

https://processing.org/reference/libraries/video/Movie.html (you will have to add library)
https://processing.org/reference/libraries/video/Movie_jump_.html

And from the Processing examples:

image

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

:slight_smile:

2 Likes