Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • A 14kHz 50% pwm is not a pwm, it is a tone of 14kHz. How accurate should the 14kHz carrier and the 500Hz modulation frequency be? It is possible with 'tone' for the 14kHz and 'millis' for the 500Hz. Commented Oct 3, 2018 at 19:50
  • Your do ... while here is an infinite loop. Commented Oct 3, 2018 at 19:50
  • Thanks for the input. I considered the tone() command as well. In this instance they are virtually interchangeable. tone() might save one step because it is automatically 50% duty, where i have to specify 50% (128) with every call of pwmWrite. Accuracy is not critical. The 14kHz tone/pwm I currently have is more than accurate enough. The 500Hz could drift around quite a bit, too. Seems like I need to set up the i variable going into the loop and increment it from inside there? Commented Oct 3, 2018 at 20:02
  • Consider using the TimerOne library to set up a timer/interrupt-based callback for the 500Hz portion, which toggles a 14kHz tone(). Commented Oct 3, 2018 at 20:08
  • Possibly this is a better way to attack from the WHILE side? (sorry, not getting code to work) ' i = 1 ; while (i<=100) { pwmWriteHR( pinout, 128 ); delayMicroseconds(500); pwmWriteHR( pinout, 0 ); delayMicroseconds(500); (i ++); }' Commented Oct 3, 2018 at 20:13