### Set PWM Resolution (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Pwm_resolution (pin, discharge, mode) - start the PWM with the selected bit - Pins: D3 (timer 2), d5 (timer 0 - will break millis/delay), D9 and D10 (timer 1) - mode: 0 (fast_pwm), 1 (Correct_PWM) -Resolution: D3 (4-8 bits), D5 (4-8 bits), D9 and D10 (4-16 bits) - the frequency in this mode is automatically maximum according to the capabilities of the timer (see table) - To change the filling, use pwm_se - the limits of filling for different discharge are indicated in the table */ ```CPP VOID PWM_RESOLUTION (Byte PIN, Byte Res, Modes Correct); ``` -------------------------------- ### Setting Custom High PWM Frequencies on Arduino Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md This example demonstrates how to use specific functions from the gyverpwm library to set custom, high PWM frequencies on Arduino pins D3, D5, D9, and D10. It initializes the pins as outputs and then calls dedicated functions for each pin/frequency combination, specifying the desired duty cycle. Note that using PWM_20KHZ_D5 will interfere with standard Arduino timing functions like millis() and delay(), and pins 9 and 10 share a timer, requiring them to operate at the same frequency. ```C++ #include VOID setup () { Pinmode (3, output); Pinmode (5, output); Pinmode (9, output); Pinmode (10, output); // these functions remove one PWM output from 8 bit timers, leaving us shim pins D3, D5, D9 and D10 on Atmega328 PWM_16KHZ_D3 (30);// SHIM 16 kHz on pin D3, filling 30 out of 255 PWM_20KHZ_D5 (50);// PWM 20 kHz on pin D5, filling 50 out of 255. Millis () and delay () will break! PWM_16KHZ_D9 (760);// SHIM 16 kHz on pin D9, filling 760 out of 1023 PWM_16KHZ_D10 (800);// SHIM 16 kHz on pin D10, filling 800 out of 1023 // Pins 9 and 10 work at the same frequency, starting on different ones will not work } VOID loop () { } ``` -------------------------------- ### Set PWM Frequency (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md // =====ward // these functions remove one PWM output from 8 bit timers, leaving us shim pins D3, D5, D9 and D10 on Atmega328 /* Pwm_freqency (pin, frequency, mode) - start the shim with the selected frequency - Pins: D3 (timer 2), d5 (timer 0 - will break millis/delay), D9 and D10 (timer 1) - mode: 0 (fast_pwm), 1 (Correct_PWM) - Frequency: 250-200'000 Hz for all timers - To change the filling, use pwm_se - The bit in this mode is given to 8 bits, in fact, the steps of the change are different! */ ```CPP VOID PWM_FREQUENCY (Byte PIN, LONG FreQ, Modes Correct); ``` -------------------------------- ### Generate Square Wave on D9 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Meander generator (square wave) on pin D9 Frequency from 2 Hz to 8 MHz, the frequency step depends on the frequency (Starting from 0.01 Hz and ending with dozens of kHz !!!) You can turn off by calling pwm_detach (9); To reset the timer into a default mode - pwm_default (9); Returns the established frequency in Herza! Frequency error 300 Hz 0.01 Hz 700 Hz 0.05 Hz 900 Hz 0.1 Hz 2 kHz 0.5 Hz 3 kHz 1 Hz 4 kHz 2 Hz 9 kHz 10 Hz 20 kHz 50 Hz 30 kHz 110 Hz 63 kHz 500 Hz 90 kHz 1000 Hz */ ```CPP Float PWM_SQUARE_D9 (Float Frequency); ``` -------------------------------- ### Attach PWM (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md // connects Shim on the selected pin (with the last settings) ```CPP VOID pwm_attach (byte pin); ``` -------------------------------- ### Launch 20kHz PWM on D5 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch of PWM with a frequency of 20 kHz on pin D5 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 8 bits (filling 0-255) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_20KHZ_D5 (Byte Duty); ``` -------------------------------- ### Launch 16kHz PWM on D9 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch of PWM with a frequency of 16 kHz (15.6 kHz) on pin D9 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - Disgusting of exactly 10 bits (filling 0-1023) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_16KHZ_D9 (inti); ``` -------------------------------- ### Launch 20kHz PWM on D9 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch PWM with a frequency of 20 kHz on pin D9 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 10 bits (filling 0-1023) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_20KHZ_D9 (inti); ``` -------------------------------- ### Launch 16kHz PWM on D10 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch of PWM with a frequency of 16 kHz (15.6 kHz) on pin D10 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - Disgusting of exactly 10 bits (filling 0-1023) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_16KHZ_D10 (inti); ``` -------------------------------- ### Launch 20kHz PWM on D10 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch PWM with a frequency of 20 kHz on pin D10 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 10 bits (filling 0-1023) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_20KHZ_D10 (inti); ``` -------------------------------- ### Launch 20kHz PWM on D3 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch of PWM with a frequency of 20 kHz on pin D3 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 8 bits (filling 0-255) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_20KHZ_D3 (Byte Duty); ``` -------------------------------- ### Launch 16kHz PWM on D5 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch PWM with a frequency of 16 kHz on pin D5 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 8 bits (filling 0-255) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_16KHZ_D5 (Byte Duty); ``` -------------------------------- ### Reset PWM Settings (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md // Reset settings corresponding to Pin Tiemer on "Standard" for Arduino ```CPP VOID pwm_default (byte pin); ``` -------------------------------- ### Launch 16kHz PWM on D3 (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Launch PWM with a frequency of 16 kHz on pin D3 - cancels PWM_FREQUENCY/PWM_RESOLATION settings - discharge is given to 8 bits (filling 0-255) - Filling changes itself (you do not need to call pwm_seet) */ ```CPP VOID PWM_16KHZ_D3 (Byte Duty); ``` -------------------------------- ### Set PWM Duty Cycle (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md /* Pwm_seet (pin, filling) - change the filling on the selected pin - PIN: D3, D5, D6,D9, D10, D11 - Filling: depends on the permission and the regime (see table) - when using pwm_frequency, the discharge is 8 bits (0-255) - When using PWM_Resolution Max.The value of the filling is equal (2^discharge - 1), also look at the table */ ```CPP VOID PWM_SET (Byte PIN, UNSIGNED inti); ``` -------------------------------- ### Detach PWM (C++) Source: https://github.com/gyverlibs/gyverpwm/blob/main/README_EN.md // Disaches the PWM on the selected pin (allows you to use digital read/WRITE) ```CPP VOID pwm_detach (byte pin); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.