Control PWM with Arduino in 5 Minutes

If you don’t want to miss my updates, remember to check the public account in the upper right corner and set it as a star, drop a star for me.

Control PWM with Arduino in 5 Minutes
Control PWM with Arduino in 5 Minutes

Many MCU manufacturers can complete PWM control through internal registers, such as Arduino, STM32, etc. This integration greatly simplifies the development process, allowing you to create applications with PWM in just 5 minutes, such as breathing lights, servo, buzzer control, etc., refer to the video below↓↓↓

3 PWM Control Application Experiments
In the video, the Seeeduino development board uses the ATmega328P, which has a total of 3 timers/counters:TC0, TC1, TC2, corresponding to different ports and PWM frequencies:
1) The frequency of TC0 PWM square wave is 980Hz, corresponding to digital IO:Output ports 5 and 6;
2) The frequency of TC1 PWM square wave is 490Hz, corresponding to digital IO:Output ports 9 and 10;
3) The frequency of TC2 PWM square wave is 490Hz, corresponding to digital IO:Output ports 3 and 11;
This means that PWM waves can be generated on ports 3, 5, 6, 9, 10, and 11.
In programming, it involves:TCCRx (control register), TCNTx (count value register), OCRx (output compare register), etc.To simplify, these registers are preset internally!Of course, if you have the ability, you can modify them yourself!
In the video, the ATmega328P code can be obtained by replying PWM on WeChat to “Darwen Says”.
END
Control PWM with Arduino in 5 Minutes
Darwen’s Must-Know Series – providing engineers with the most commonly used and needed knowledge points, please continue to follow the common components series, common bus series, and common interface series.
Review of previous issues of “Darwen’s Must-Know Classroom”:
  • Issue 1: Deep dive into the minimal resistance, most functional 0-ohm resistor, saving your design

  • Issue 2: If you still don’t understand why the power pins have capacitors after watching, then change your career

  • Issue 3: Directly hitting the “heart” of digital circuits, understand crystal oscillators in 10 minutes

  • Issue 4: Example to answer how inductors work?

  • Issue 5: Filter circuit literacy – have you mastered these knowledge points?

  • Issue 6: How to reasonably use diodes in circuit design?

  • Issue 7: PID hard to understand? Math + examples tell you why to use PID control

  • Issue 8:Quickly adjust PID controllers from the time domain! Building closed-loop control systems is that simple

  • Issue 9:Analog electronics difficulties: 8-minute detailed explanation of the current amplification effect of transistors

  • Issue 10: Too many pitfalls in circuit design? Get the timing/heat dissipation/power devices/EMC pit avoidance guide

  • Issue 11:Analog electronics difficulties:Field effect transistors (MOSFET) are just an electrically controlled switch?

  • Issue 12: “Small size and large capacity” introduction of the $1 microcontroller i.MX RT series

  • Issue 13:Improper power-up, the chip is done for

  • Issue 14:What is the difference between digital and analog electronics?

  • Issue 15:Classification and determination methods of feedback

  • Issue 16:Difference between closed-loop feedback and open-loop feedback

  • Issue 17:What impact does AC component have in amplifiers?

Control PWM with Arduino in 5 Minutes

Leave a Comment

×