Search code examples
arduinointegerpwm

Make PWM signal with arduino


First sorry for my bad English and I hope u understand what I mean

I want make a PWM signal with 50% duty cycle and (f) frequency (f is an integer)

for example make 50hz signal when f=50 and 2000hz signal when f=2000

how can I do it ????


Solution

  • If that's all you need to do, then the tone() function does it. Read the language reference and get familiar with all it has for you. Have fun!

    https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/