RGBIO控制

红  绿    蓝      颜色

1    0     0        红

0    1     0        绿

1    1     0        黄

0    0     1        蓝

1    0     1        紫

0    1     1        浅蓝

1    1     1        白

 

颜色变化:红 -> 黄 -> 绿 -> 浅蓝 -> 蓝 -> 紫 -> 白

                 100  |110  | 010  | 011   | 001 | 101 |111

if((PWM_Coloured_RED_Flag==0)&&(PWM_Coloured_GREEN_Flag==0))
 {
  PWM_Coloured_RED_Value--;
  if(PWM_Coloured_RED_Value<=0)
  PWM_Coloured_RED_Flag=1;
 }
 if((PWM_Coloured_RED_Flag==1)&&(PWM_Coloured_GREEN_Flag==0))
 {
  PWM_Coloured_GREEN_Value--;
  if(PWM_Coloured_GREEN_Value<=0)
  PWM_Coloured_GREEN_Flag=1;
 }
 if((PWM_Coloured_RED_Flag==1)&&(PWM_Coloured_GREEN_Flag==1)&&(PWM_Coloured_BLUE_Flag==0))
 {
  PWM_Coloured_RED_Value++;
  if(PWM_Coloured_RED_Value>=100)
  PWM_Coloured_RED_Flag=0;
 }
 if((PWM_Coloured_RED_Flag==0)&&(PWM_Coloured_GREEN_Flag==1)&&(PWM_Coloured_BLUE_Flag==0))
 {
  PWM_Coloured_BLUE_Value--;
  if(PWM_Coloured_BLUE_Value<=0)
  PWM_Coloured_BLUE_Flag=1;
 }
 if((PWM_Coloured_RED_Flag==0)&&(PWM_Coloured_GREEN_Flag==1)&&(PWM_Coloured_BLUE_Flag==1))
 {
  PWM_Coloured_GREEN_Value++;
  if(PWM_Coloured_GREEN_Value>=100)
  PWM_Coloured_GREEN_Flag=0;
 }
 if((PWM_Coloured_RED_Flag==1)&&(PWM_Coloured_GREEN_Flag==1)&&(PWM_Coloured_BLUE_Flag==1))
 {
  PWM_Coloured_GREEN_Value++;
  if(PWM_Coloured_GREEN_Value>=100)
  PWM_Coloured_GREEN_Flag=0;
  
  PWM_Coloured_BLUE_Value++;
  if(PWM_Coloured_BLUE_Value>=100)
  PWM_Coloured_BLUE_Flag=0;
 }

 

posted on 2020-05-07 17:49  行星夜  阅读(227)  评论(0编辑  收藏  举报

导航