Copy everything below the line and using a text editor paste it into a file titled, “USBController.ino”
Back to the Remotely actuated intervalometer for aerial mapping page
———————————————————————————————–
// Canon Arduino Controller // Arduino pin 10 is input from RC receiver // Arduino pin 12 is output to camera USB // Arduino pin XX is +5 volts from RC receiver // Arduino pin XX is ground // Set up initial variables: int led = 13; int PWM_In = 10; int USB_Power_Out = 12; unsigned long duration; int ActiveState; int STANDBY = 0; int RECORDING = 1; int SHUTDOWN = 2; // The following sets the PWM levels from the RC receiver: // Low PWM=standby, medium PWM=record, high PWM=shutdown int StartState = 1250; int RecordStateStart = 1350; int RecordStateEnd = 1650; int ShutdownStart = 1750; // End set up initial variables // Setup routine runs once when you press Arduino reset button: void setup() { // Initializes pin 12 and pin 13 (LED) as digital outputs pinMode(led, OUTPUT); pinMode(USB_Power_Out, OUTPUT); // Initializes pin 10 as digital input pinMode(PWM_In, INPUT); Serial.begin(9600); digitalWrite(USB_Power_Out, LOW); } // This loop routine runs until shutdown: void loop() { duration = pulseIn(PWM_In, HIGH); // Check whether input signal is for standby, record or shutdown: if (duration <= StartState) {ActiveState = STANDBY;} else if (duration >= RecordStateStart && duration <= RecordStateEnd) {ActiveState = RECORDING;} else if (duration >= ShutdownStart) {ActiveState = SHUTDOWN;} // If Standby mode, output 15 msec pulses: if (ActiveState == STANDBY) { digitalWrite(USB_Power_Out, HIGH); digitalWrite(led, HIGH); delay(15); digitalWrite(USB_Power_Out, LOW); digitalWrite(led, LOW); } // If Record mode, output 45 msec pulses: if (ActiveState == RECORDING) { digitalWrite(USB_Power_Out, HIGH); digitalWrite(led, HIGH); delay(45); digitalWrite(USB_Power_Out, LOW); digitalWrite(led, LOW); } // If Shutdown mode, output 90 msec pulses: if (ActiveState == SHUTDOWN) { digitalWrite(USB_Power_Out, HIGH); digitalWrite(led, HIGH); delay(90); digitalWrite(USB_Power_Out, LOW); digitalWrite(led, LOW); } delay(200); }