sending 2ms pulse (PWM) to MAPIR survey 2 camera for triggering


I am trying to interface my laptop with the camera (MAPIR survey 2). I am sending a signal (serially) from the laptop (using matlab) so that Arduino will generate a 2ms PWM pulse of 3.3 volts. The camera only takes pictures when the pulse is between 1.8 to 2 ms. I used analogWrite function to creat this pulse but in my oscilloscope, I am observing a 5 volts pulse with approximately 5ms width even though I have given a delay of 2ms before setting the PWM pin to low.

Also, since I need only one pulse per picture, I wanted to know if I need to calculate duty cycle (because every topic related to PWM had a small discussion on duty cycle).

A brief description on the sketch:
The sketch I have attached has both a button as an interrupt for triggering the camera and a command waiting for a signal from USB to click pictures 3 times. the waiting period between two triggers is 3 seconds as per the camera specification.

test3.ino (2.33 KB)

You probably solved this, so hopefully this will be helpful to other people.

I have tried several methods on generating a pulse train to trigger a Mapir Survey2, and found that simply sending a tone pulse out seems to work very well and much easier than PPM and digitalWrite blocks:

// Camera trigger digitalWrite(ledPin, HIGH); tone(tonePin, 250); //This can be about +- 30ms delay(100); //100 to 200 seems to work digitalWrite(ledPin, LOW); noTone(tonePin);