Digital imput via arduino to processing

Zenolin:
Sorry, was bad coment, now I changed. How now ?

So far I haven't seen a single line of code that you have posted with the [ code ] tags as we have repeatedly requested. You want people to help you but are not prepared to take a couple of minutes to work out how to do that.

Your comments do not agree with the code you post. That shows a lack of attention to detail. Detail is what makes programs work. The computer cannot read your mind, nor can we. Code like this (bearing in mind the comments) show a total confusion on your part:

int switchPin = 4;                       // Switch connected to pin 4

...
  pinMode(switchPin, INPUT);      // Set pin 0 as an input

Meanwhile comments like this, while correct:

  if (val == 2) {              // If the serial value is 2,

... simply do not add anything at all to the code.

Imagine if I said this:

if (a == 2)   // if a is 2

What has the comment done? Has it helped in any way?

Or this:

a = 42;   // make a have the value 42

Try to think clearly. Programming is not about writing "stuff that looks like programs". It is about understanding what you are doing.