发 帖  
原厂入驻New
张飞60小时讲透半桥串联谐振软开关电源设计,立即学习!
[问答] 怎么改变LED占空比
35 LED
分享
我需要写一个C18程序,它将改变ICD2上LED的占空比。占空比将通过按下一个开关来改变,并将循环通过4个不同的占空比。默认值为0%(总是在ON),然后是10、50和100。频率将是0.1赫兹,所以对于50%,它将在5秒关闭5秒。你最后一次按下开关,它会回复到0%占空比。我的方法是创建一个案例结构。将根据按下按钮的次数来选择实例结构。程序将以一个简单的IF语句开始;如果按下按钮,则递增一个COUNT,然后执行适当的情况。当它在一个实例循环中,我开始画一个空白。寻找任何帮助。谢谢

以上来自于百度翻译


      以下为原文

    I need to write a C18 program that will change the duty cycle of an LED on a ICD2.  The duty cycle will be changed by pressing a switch and will cycle through 4 different duty cycles.  The default will be 0% (always on) then 10,50, and 100.  The frequency will be 0.1 Hz so for 50% it will be on for 5 seconds off for 5 seconds.  The last time you press the switch it will revert back to the 0% duty cycle.  My approach was going to be to create a case structure.  The case structure would be selected based on how many times the button was pressed.  The program would start with a simple if statement; if the button is pressed, increment a COUNT then peRForm the appropriate case.  When its in one of the case loops is where I start to draw a blank.  Looking for any help.   Thanks
0
2019-6-14 06:29:54   评论 分享淘帖 邀请回答
1个回答
后退一步。从如何打开LED开始,然后让LED在指定的时间等待(比如说1秒),然后关闭LED,等待另一个指定的时间(比如2秒),然后重复。先让工作开始,让我们知道你在做什么。

以上来自于百度翻译


      以下为原文

    Take a step back.  Start by figuring out how to turn on an LED, then leave the LED on an wait for a specified time (say 1 second), then turn the LED off, wait for another specified time (say 2 seconds), and repeat.  Get that working first and let us know how you are doing.
2019-6-14 06:35:55 评论

举报

只有小组成员才能发言,加入小组>>

43个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /10 下一条

快速回复 返回顶部 返回列表