How can I send a single serial (processing & Arduino)

Hey guys I am using a Kinect to control the on and off of a LED. it shoots 1’s and 0’s to Arduino.
The only problem is it’s continues, using the printing I can see it shoots millions of 1’s and 0’s at a time
how can I make it so it doesn’t send the inputs continuously?

here is my processing code:

import org.openkinect.processing.*;
import processing.serial.*;

Kinect kinect;
Serial myPort;

PImage img;  


void setup() {



  size(6, 6); 
  kinect = new Kinect(this); 
  kinect.initDepth(); 
  img = createImage(kinect.width, kinect.height, RGB); 
  String portName = Serial.list()[9]; //change the 0 to a 1 or 2 etc. to match your port
  myPort = new Serial(this, portName, 9600);
}  

void draw() { 
  background(0); 

  img.loadPixels(); 


  int[] depth = kinect.getRawDepth(); 

  float sumX =0;
  float sumY =0; 
  float totalPixels = 0; 


  int skip = 50;

  for (int x = 0; x < kinect.width; x+=skip) { 
    for (int y = 0; y < kinect.height; y+=skip) {
      int offset = x + y * kinect.width; 
      int d = depth[offset]; 


      //if int );

      if ( d  > 300 && d < 500) {
        img.pixels[offset] = color(255, 255, 255);
        myPort.write('1');         //send a 1
        println("1");
      
    } else {  
        img.pixels[offset] = color(0);
        myPort.write('0'); 

        {

          img.updatePixels(); 
          image(img, 0, 0);
        }
      }
    }
  }
}

And of course the Arduino code:

 char val; // Data received from the serial port
 int ledPin = 13; // Set the pin to digital I/O 13
 void setup() {
   pinMode(ledPin, OUTPUT); // Set pin as OUTPUT
   Serial.begin(9600); // Start serial communication at 9600 bps
 }
 void loop() {
   if (Serial.available()) 
   { // If data is available to read,
     val = Serial.read(); // read it and store it in val
   }
   if (val == '1') 
   { // If 1 was received
     digitalWrite(ledPin, HIGH); // turn the LED on
   } else {
     digitalWrite(ledPin, LOW); // otherwise turn it off
   }
   delay(10); // Wait 10 milliseconds for next reading
}

Thanks everyone

void loop() {
   if (Serial.available()) 
   { // If data is available to read,
     val = Serial.read(); // read it and store it in val
     if (val == '1') 
    { // If 1 was received
      digitalWrite(ledPin, HIGH); // turn the LED on
    } else {
      digitalWrite(ledPin, LOW); // otherwise turn it off
    }
   }
   
   delay(10); // Wait 10 milliseconds for next reading
}

only call digitalWrite() when you receive something valid from Serial

how can I make it so it doesn't send the inputs continuously?

Don't process the image data over and over. The Processing app has a setup() function, for one time stuff, and a draw() function for things that are to happen over and over. Don't do stuff in the over and over function that you want done one time.