HELP MaxMSP

hello, i am begener with arduino, i am testing the sony lanc protocol with arduino

something i don't understand in the READ ME NOTE :

What is it:

A MaxMSP(or Pd, or Any Serial App) to LANC Camera via Arduino Controller

Ok this a little rough, but works fine.

Steps:

OK 1. Make a Lanc Cable & Connect Up the Ardunio

This is an "open connector" which i fully understand. Have a look below. Anyway get a 2.5" Stereo Connector from you local electronics store.
This is a Ring, Tip, Sleeve connector.

  • Connect the Sleeve to GND of the Arduino Board
  • Connect the Tip to the Digital PIN #3 on the Arduino Board

OK3. Build and Upload Ardunio Firmware

This is in Lanc_Ardunio.pde (Tested with Ardunio 10)

What is it ? how to do it ?4. Run Max Patch

My patch only zooms at the moment but any "Special Command to Videocamera" (Ox28) can be sent.
Just send the following from your patch/serial programm

HEX CODE MEANING
00 variable speed zoom Tele: slowest speede

Lanc_Ardunio.pde is the source code for an Arduino program, called a "sketch". It's in a language that's based on C, with certain simplifications. The Arduino IDE (Integrated Development Environment) will accept that code as input, compile it into machine code for the Arduino, and upload that (in hex) to the chip. The sketch code then runs on the microcontroller chip in the Arduino and communicates back to the host, which meanwhile is running Max/MSP.

Thank you
i made the compilation and uploaded to the arduino
but nothing hapen

perhaps there is somethink misin in the code because there is no push buton

#define rxPin 2 // Receive Status from LANC Device (unimplemented)
#define txPin 3 // Send Commands to LANC DEVICE (works)
#define ledPin 13 // LEB for activity status flickering
#define bitMicroSeconds 104

byte ledPinState = 1;

void setup() {
Serial.begin(57600); // 9600, 14400, 38400, 57600, 115200

// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(ledPin, OUTPUT);

// Blink LED 13 Just to Say 'Hello'
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(1000);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}

int block = 0;
int state = 0;
int in = 0;

void loop() {

int inBytes = Serial.available();

if (inBytes == 0) return;

if (inBytes >= 128) {
Serial.print(0,BYTE);
// Serial.flush();
return;
}
in = Serial.read();

if (in == 99) return;

/* switch (state) {
case 0 :
state = OkState(in);
return;
case 99: // ASCII 'c' for control
/
SendCode(40,in); // 40 == 0x28 "Special command to videocamer"
SendCode(40,in);
toggleLed();
Serial.print(in,BYTE);
/

state = 0;
return;
default:
state = 0;
return;
}
*/
}

/*
//READ
//Serial.print("S: ");
frameStartBitWait();
for(int byteNum = 0; byteNum < 8; byteNum++) {
byte in = readByte(rxPin,104);
lowWait(rxPin);
Serial.print(in,DEC);
if (byteNum!=7)
Serial.print(".");
else
Serial.println(";");
}

*/

void SendCode(int type,int code) {
frameStartBitWait();
writeByte(rxPin,type,bitMicroSeconds); // Video Cam Control
lowWait(rxPin);
writeByte(rxPin,code,bitMicroSeconds); // Tele/Wide
}

void lowWait(int pin) {
byte in = digitalRead(pin);
while (in) {
in = digitalRead(pin);
}
}

void frameStartBitWait() {
// finds thge start of a telegram/frame
unsigned long usec = pulseIn(rxPin,HIGH);
while (usec < 5864) { // 6230 experimentally with a RTV900
usec = pulseIn(rxPin,HIGH);
/* DEBUG
Serial.print(usec);
Serial.println(" microseconds");
*/
}

/* DEBUG
Serial.print("frame start after ");
Serial.print(usec);
Serial.println(" microseconds");
*/
}

byte readByte(int pin,unsigned long uSec /* bit width*/ ) {
byte result = 0;
delayMicroseconds(uSec * 1.5); // skips the Start Bit and Land in the midlle of the first byte

for (int i = 0; i < 8; i++) {
if (digitalRead(pin) == LOW) { // == LOW because bits inverted in LANC
result++;
}
result <<= 1;
delayMicroseconds(uSec);
}
delayMicroseconds(0.5*uSec);
return result; // return happens at end of last (8ths) bit
}

void writeByte(int pin, byte value, unsigned uSec /* bit width */) {
delayMicroseconds(uSec); // wait for stop bit
pinMode(pin,OUTPUT);
for (int i = 0; i < 8; i++) {
boolean bit = value & 0x1;
digitalWrite(pin,!bit); // NOT (!) pin because all data is inverted in LANC
value >>= 1;
delayMicroseconds(uSec);
}
pinMode(pin,INPUT); // return happends at end of last (8th) bit
}

void toggleLed() {
// set the LED pin using the pinState variable:
digitalWrite(ledPin, ledPinState);
// if pinState = 0, set it to 1, and vice versa:
ledPinState = !ledPinState;
}

thank you for your answer
this program is supose d to control the zoom of the camera
but no buton no swith so how to send the comand ?
somethoing i don't understand
philippe