1410 views|0 replies

1w

Posts

25

Resources
The OP
 

[SAMR21 New Gameplay] 5. Graphical Programming - Breathing Light 1 [Copy link]

 

Many GPIOs of SAM R21 support PWM output function, so it is also very easy to implement the breathing light function. You only need to change the duty cycle of the PWM output periodically to change the brightness of the LED.

In graphical programming, the PWM function is implemented through the analog write pin module. Although the name is analog output, it is actually PWM output.

We first create a variable "brightness" to represent the PWM output value. In MakeCode programming, Chinese variable names are allowed, which is easy to use and understand. In the forover (infinite loop), change the brightness of the variable in the cycle. Because the PWM output is 10-bit precision, it must not exceed 1024. A complete program is as follows. Click Download and copy it to the development board, then you can run it.



This content is originally created by dcexpert , a user of EEWORLD forum. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list