int byte0;int eCommand; //Current LANC command to send to video cameraint nDetectedStatus; //Status returned by LANC busbyte nCommandTimes; //LANC requires at least 5 times to repeat the command to video camera. This will count that.int nFlashCounter; //Counter to flash leds so they save battery power (as opposed to be always ON)

//search for 4ms gap -at least- being high continuosly. //This worked extraordinarily well in my European Sony video camera //but it may not work on a NTSC camera, you may need to reduce the //loop limit for that (hopefully not). Please send me details //in that case to make it available to the community.

//Now wait till we get the first start bit (low) while (digitalRead(PinLANC)==HIGH) delayMicroseconds(25);

}

void SendCommand(unsigned char nCommand){ //Note bits are inverted already by the NPN on open collector //(when it is switched ON by a vbe>0.7v, the vce will be close to zero thus low state for LANC) //This is exactly what we want and how LANC bus works (tie to GND to indicate "1")

//infinite loop, I do not want to get out of here ever. //It is more efficient than let loop() function to do //that, as it requires a function call and then a loop //like this one. Well, I prefer my own efficient loop //instead. This increase chances of AfterLongGap() having //time enough for what it needs to be done.