1

I need variable frequency output - 0-5000Hz with some duty cycle. I do not want to change timers, because I am using delays, serial and CAN, so I do not want them to be affected by changed timers. I need this for VDO speedometer, which is driven by variable frequency.

Is it possible to set variable time interrupts and change them accordingly to what frequency I want?

5
  • 1
    Yes, possible, by changing the settings of a timer. Don't know much about CAN. But a hardware Serial interface doesn't depend on any timer. And delays also use Timer0. Even the Arduino Uno has 3 Timers I think. There should be one available to use for you
    – chrisl
    Aug 26 at 8:14
  • timers, as I understand, need to be changed by their prescalers, but what if I want an exact value of frequency? Something like delay()?
    – Voyze
    Aug 26 at 8:22
  • Try using tone()...
    – Majenko
    Aug 26 at 8:55
  • 1
    For changing the timer frequency you can also use the output compare mode, where the timers runs up to a value, that you write into the output compare registers (OCR...). So the frequency can be adjusted with rather high resolution (depending on the used timer). Why don't you want to use timers? Try using tone() would be the easiest. It also uses a Timer.
    – chrisl
    Aug 26 at 9:55
  • YES! Thank you, tone() works perfectly
    – Voyze
    Aug 26 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.