Arduino Uno and processing


i'm doing a project with the arduino uno and processing to start a movie when a PIR sensor is triggered. To connect the two systems i used this tutorial: But i don't know anything about editing codes(or how to) i also copied the code given for processing but it just doesn't do anything. I realy could use some help here ):

Right now i use these codes:

For Arduino:

void setup(){ Serial.begin(9600); pinMode(13,OUTPUT); pinMode(2,INPUT); Serial.println("start"); }

void loop(){ digitalWrite(13,digitalRead(2)); Serial.print(digitalRead(2)); delay(100); };

For processing:

String PATH = "C:/Users/Dirk-Jan/Documents/sketch_2/child44.mp4" ; Movie myMovie;

void setup() { size(960, 400); frameRate(23); myMovie = new Movie(this, PATH); myMovie.loop(); }

void draw() { image(myMovie, 0, 0); }

// Called every time a new frame is available to read void movieEvent(Movie m) {; }

boolean b = false;

void keyPressed() {

if (b== false) { myMovie.pause(); b= true; }

if (b== true) {; b= false; }


You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :)

It looks to me like you had better do a little studying, both on 'Processing' and Arduino coding.

With Arduino at least, start by checking out the most basic examples then working your way up. The "Blink" example is the best place to start.

In 'Processing', (as with Arduino), you need to study up on serial communications.

You have a fair way to go with both.

Your Arduino sketch sends "start" when it starts up. Then, every 100 milliseconds, it sends "0" or "1", depending on whether the switch is pressed or not, or guessing, depending on how the switch is wired.

Your Processing sketch does not connect to the Serial port that the Arduino is talking to. It does not read the data that the Arduino is sending. Instead, it relies on a key on the PC keyboard being pressed, or not, to determine what to do.

Hi PaulS,

I'm realy new in this, and to be honest i didn't even create these codes. Can you tell me how i can make the arduino and processing communicate? The "switch" i think is the PIR sensor? and how does the wiring influence the codes? these are propably very newby questions but honestly i don't know anything about these systemI:


The "switch" i think is the PIR sensor?

Do you really need to guess? Look at the hardware. You are the ONLY one that can see it. Is there a PIR sensor attached to digital pin 2?

If so, you are already sending data to the serial port. Now, all you need to do is to get Processing to open the serial port that the Arduino is talking to. There are several examples that come with Processing that show how to do that.

Making use of the data is up to you.