Step 15Writing The Code
The process is very much the same, however. We define some names for each pin so that the code is more understandable.
Then, we write the init function again, but this time we set all of Port D to be output and only one pin on Port C to be output - the LED we added last time.
Next, we write the actual shoot function. The premise is simple, each on/off cycle for the LED takes 26uS, we divide up the pulses into 26uS chunks and then repeat on/off cycles that many times. Pauses in-between pulses are just normal delays. The code is commented as to how the timings are worked out. The loops are just for loops.
The main program is pretty simple. We initialise our input/output. Then, we go into the infinite loop, turn on the LED (not status LED) and call the shoot function. We then turn off the LED and wait 5 seconds. This loop will repeat endlessly.
If you want a really really simple intervalometer, you just made one. Simply set the delay to whatever you need (there is a Delay_s function too) and the program will loop until you turn the power off.
Upload your code to the micrcontroller as before, remember to connect up the crystal/capacitors. Test out your program and check out the range. LEDs are pretty directional so you'll need to point it more or less normal to the camera's IR port to guarantee a picture at a longer range. At a right angle to the camera, i got about 2m range. Facing the chip head on i got around 5-10m+. This range will decrease somewhat outside, but it will still work if you hold the emitter close to the camera.
Next up, buttons.
Code.zip66 KB| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|























































