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 Commented Aug 26, 2021 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()? Commented Aug 26, 2021 at 8:22
  • Try using tone()... Commented Aug 26, 2021 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. Commented Aug 26, 2021 at 9:55
  • YES! Thank you, tone() works perfectly Commented Aug 26, 2021 at 10:08

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.