RGB鍏ㄥ僵LED鈥斺€旀爲鑾撴淳鍩轰簬C璇█鏁欑▼

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RGB鍏ㄥ僵LED鈥斺€旀爲鑾撴淳鍩轰簬C璇█鏁欑▼相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/error' title='error'>error   c璇█   ret   nbsp   class   erro   ini   set   print   

 1 #include <stdio.h>
 2 #include <wiringPi.h>
 3 #include <softPwm.h>
 4 
 5 const int Red_Pin = 9;
 6 const int Green_Pin = 10;
 7 const int Blue_Pin = 11;
 8 
 9 void RGB_Color_Init()
10 {
11     softPwmCreate(Red_Pin, 0, 100);
12     softPwmCreate(Green_Pin, 0, 100);
13     softPwmCreate(Blue_Pin, 0, 100);
14 }
15 
16 int main()
17 {
18     if(wiringPiSetup() == -1)
19     {
20         printf("Error!
");
21         return 1;
22     }
23     RGB_Color_Init();
24     while(1){
25         for(int i = 255; i >= 0; i--)
26         {
27             softPwmWrite(Red_Pin, i);
28             softPwmWrite(Green_Pin, 128-i);
29             softPwmWrite(Blue_Pin, 255-i);
30             delay(10);
31         }
32         for(int i = 0; i <= 255; i++)
33         {
34             softPwmWrite(Red_Pin, i);
35             softPwmWrite(Green_Pin, 128-i);
36             softPwmWrite(Blue_Pin, 255-i);
37             delay(10);
38         }
39     }
40     return 0;
41 }

 

以上是关于RGB鍏ㄥ僵LED鈥斺€旀爲鑾撴淳鍩轰簬C璇█鏁欑▼的主要内容,如果未能解决你的问题,请参考以下文章