Send int (0-1024) value from digital pin to Max/MSP

Hello i'm trying to send a value i receive from the digital pin 9 to max msp.

I have connected a 1M ohm resistor from digital pin 9 to digital pin 4 and i have connected a alluminium foil from pin 9 to a plant. i'm now getting a stream of numbers from pin 9 around 0-1024 and i would like to send this value to maxmsp. is there a way i can do this? here my ino patch.

#include <CapacitiveSensor.h>

CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,9); // 1M resistor between pins 4 & 9, pin 9 is sensor pin, add a wire and or foil

void setup()                    
{   
   Serial.begin(9600);
   //digitalWrite(8,HIGH);
   cs_4_9.set_CS_AutocaL_Millis(0xFFFFFFFF);// turn off autocalibrate on channel 1 - just as an example
   
   pinMode(7,OUTPUT);
}

void loop()                    
{
  Serial.begin(9600);
  long sensor1 =  cs_4_9.capacitiveSensor(50);

    Serial.write(sensor1);  // print sensor output //
      if(sensor1 >= 1200)
   {
    digitalWrite(7,HIGH);
   }
   else{
    digitalWrite(7,LOW);
   }
   delay(100);
    
}

void sendValue (int sensor1){
  Serial.write(sensor1);
}

Hi.
OPs pic.

What is maxmsp. ?
Link to data/spec.

Tom.... :slight_smile:

See: Arduino Playground - MaxMSP