Aide

qui peut m'aidé a comprendre ce program
c'est pour faire une telecomande LANC pour camescope sony

je je sait pas coment le modifier pour envoyer les comande au camescope

merci d'avance

#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;
}

up

Ah oui j'avais oublié :slight_smile: je regarde.

Ben c'est simple, il suffit de te connecter via une liaison série à l'Arduino, et d'envoyer un octet correspondant à une commande, et il se charge de l'envoyer via le LANC.

Bon... à mon avis il faut reprendre du début : qu'est ce que tu veux faire et qu'est ce qui te gêne dans ce code ?

j'envoie les octets via le serial monitor
mais rien
exemple 27 ou 29 ect
27 rec start (DV)
29 rec stop (DV)

c'est exayer d'envoyer les octed en Hex , idem rien

au demarge la led pin 13 s'alume bien
puis quand j'envoie un octet la petite led rx clinote
la conection de l'arduino ver la camera est 100% bonne, je vais la reverifier pour la dixieme foi au cas ou

j'aie testé les autre soft basique d'arduino ex:des led cela marche bien

je doit me tromper quelque part peut etre les octet a envoyer

voici le fichier read me

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:

  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
  1. Build and Upload Ardunio Firmware

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

  1. 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 speed
02 variable speed zoom Tele: faster than 00
04 variable speed zoom Tele: faster than 02
06 variable speed zoom Tele: faster than 04
08 variable speed zoom Tele: faster than 06
0A variable speed zoom Tele: faster than 08
0C variable speed zoom Tele: faster than 0A
0E variable speed zoom Tele: fastest speed
10 variable speed zoom Wide: slowest speed
12 variable speed zoom Wide: faster than 10
14 variable speed zoom Wide: faster than 12
16 variable speed zoom Wide: faster than 14
18 variable speed zoom Wide: faster than 16
1A variable speed zoom Wide: faster than 18
1C variable speed zoom Wide: faster than 1A

pour l'instant il n'arrive qu'à zoomer donc apparemment pas la peine d'essayer d'enregistrer, ce n'est pas au point.

est-ce que le câble est bon ?

Mon cable est bon
mais je n'arrive meme pas à zoomé de toute façon
je vaie refaire des test pour voir
merci pour tes reponses