I'm porting a code from c in the Arduino platform (I'm using an Arduino Leonardo). I wanto to remote control a camera with an IR LED. The info about the remote control want to emulate here. The code, here.

The Burst frequency to drive the IR LED is 32700 Hz, and i'm trying to make Arduino runs at this frequency.

I've not an engeneering background so i don't really know what to do. I think i need some kind of delay to make Arduino run at that frequency, there is a note on the frequency in the second link i gave:

Before compilation, the microcontroller clock frequency must be specified [...]

In case the IR light is visible and the camera not responding: [...] check the program timing. The _delay_us() routines in the code need a proper setting of the F_CPU variable.

EDIT: i'm posting because i have tried the code in here but it seems to be some communication problem with the IR signal emitted: not every time the LED blink (i have tested with a cellphone cam and it blinks at specified times) the camera is shooting.

  • 2
    \$\begingroup\$ I don't have a time for a proper answer, but I have few comments: 1. If you want to generate signal at 32 kHz, you don't want to run the Arduino at that frequency. The F_CPU parameter is used to calculate for how long the Arduino should wait before doing more processing. Here's a link which describes the changes. The examples there change the F_CPU from 16 MHz to 8 MHz (which is opposite of what you want to do). \$\endgroup\$
    – AndrejaKo
    Commented Nov 15, 2012 at 23:21

1 Answer 1


The code in your example is written for a 7.9MHz clocked CPU:

#define F_CPU 7900000 // clock frequency, set according to clock used!

Whereas Arduino runs at 16MHz. Since all delays in the code _delay_ms(HPERIOD); are in milliseconds, you should be just fine by deleting that first F_CPU line from the source and recompiling it. Arduino automatically uses the correct frequency for for your board (16MHz).

  • \$\begingroup\$ ok thank you! Anyway, i have found interesting to try to made arduino runs slowly. can you add in the answer some more generally point on how to make arduino runs at different hz? \$\endgroup\$
    – nkint
    Commented Nov 16, 2012 at 10:26
  • 1
    \$\begingroup\$ If you want the processor to run at different frequencies, you'll have to change the crystal, and you're not ready to do that yet. \$\endgroup\$
    – Matt Young
    Commented Nov 16, 2012 at 14:26
  • 1
    \$\begingroup\$ Changing the clock frequeny will break the bootloader. You won't be able to load new programs on the Arduino. \$\endgroup\$
    – jippie
    Commented Nov 16, 2012 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.