Bluno M3 PWM

2015-01-041.2万
AI 快速预览详细 收起
本文介绍了Bluno M3的PWM功能,详细讲解了如何使用analogWrite()函数控制LED亮度。通过逐步调整亮度值,可以实现LED的渐变效果。适合初学者入门学习,帮助你快速掌握PWM的基本应用。


目录:
    概述
    PWM 参考函数
    参考例程

1.概述
PWM是该模块的基础功能,Bluno M3板子上标有波浪号的端口都是PWM口(0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12 , 14, 27, 28, 35, 36, 37, 38),其中5、9、14是模拟,其他都是硬件定时器产生。

2.PWM 参考函数
analogWrite()

3.参考例程

  1. int ledPin = 0;    // LED connected to digital pin 0
  2.         
  3. void setup()
  4. {         
  5. //nothing happens in setup        
  6. }        
  7. void loop() {         
  8.         // fade in from min to max in increments of 5 points:         
  9.         for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5)
  10.         {            
  11.                     
  12.                 analogWrite(ledPin, fadeValue);         // sets the value (range from 0 to 255):            
  13.                     
  14.                 delay(30);          // wait for 30 milliseconds to see the dimming effect        
  15.         }        
  16.         // fade out from max to min in increments of 5 points:         
  17.         for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5)
  18.         {            
  19.                 analogWrite(ledPin, fadeValue);           // sets the value (range from 0 to 255):        
  20.                
  21.                 delay(30);                              // wait for 30 milliseconds to see the dimming effect         
  22.         }        
  23. }
复制代码


创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(2)
Grey
Grey
建议楼主做一个目录,把所有关于M3的资料和相关教程都放在里面,方面后人查阅
hnyzcj
hnyzcj
顶一个呀
- 没有更多了 -