远程同步灯灯光效果子程序
时间:08-25
来源:互联网
点击:
前面一篇文章里我们介绍了单片机远程同步灯的电路和主程序,地址:http://www.51hei.com/mcu/1171.html,根据大家都要求我把灯光效果子程序也在此公开,大家在制作的过程中遇到什么问题可在本文评论中提出,我会尽量为大家解决。
void zhuizhu(void){uchar i;for(i=0;i8;i++){P0=zhui;delay();}for(i=0;i8;i++){ if(i+812)P0=zhui;P1=zhui;delay();}for(i=0;i13;i++){ if(i+812)P1=zhui;P2=zhui;delay();}P2=0x00;}void liushui(void){uchar i,j,k; P0=0x00;P1=0x00;P2=0x00;delay();for(i=0;i8;i++){ P0|=SET(i); delay();}for(j=0;j8;j++){ P1|=SET(j); delay();}for(k=0;k8;k++){ P2|=SET(k); delay();}for(k=0;k8;k++){ P2=CLR_TO_R(k); delay();}for(j=0;j8;j++){ P1=CLR_TO_R(j); delay();}for(i=0;i8;i++){ P0=CLR_TO_R(i); delay();}}void RGBjianbian(void){uchar x;uchar i,j;//=================红灯渐亮又渐暗 for(x=0;xLOG;x++){ for(i=0;iLOG;i++){P0=0x49;P1=0x92;P2=0x24;}for(j=0;jLOG-x;j++){ P0=0x00;P1=0x00;P2=0x00;}} //灯从不亮到最亮 P36=1;for(x=0;xLOG;x++){ for(i=0;iLOG;i++){ P0=0x00;P1=0x00;P2=0x00;}for(j=0;jLOG-x;j++){P0=0x49;P1=0x92;P2=0x24;}} //从最亮又到暗 P0=0x00;P1=0x00;P2=0x00; //================================//================绿灯渐亮又渐暗 for(x=0;xLOG;x++){ for(i=0;iLOG;i++){P0=0x92;P1=0x24;P2=0x49;}for(j=0;jLOG-x;j++){ P0=0x00;P1=0x00;P2=0x00;}} //灯从不亮到最亮 for(x=0;xLOG;x++){ for(i=0;iLOG;i++){ P0=0x00;P1=0x00;P2=0x00;}for(j=0;jLOG-x;j++){P0=0x92;P1=0x24;P2=0x49;}}//==============蓝灯变化 P0=0x00;P1=0x00;P2=0x00; for(x=0;xLOG;x++){ for(i=0;iLOG;i++){P0=0x24;P1=0x49;P2=0x92;}for(j=0;jLOG-x;j++){ P0=0x00;P1=0x00;P2=0x00;}} //灯从不亮到最亮 for(x=0;xLOG;x++){ for(i=0;iLOG;i++){ P0=0x00;P1=0x00;P2=0x00;}for(j=0;jLOG-x;j++){P0=0x24;P1=0x49;P2=0x92;}}P0=0x00;P1=0x00;P2=0x00; }void shanshuo(void) {P0=0x0f;P1=0x0f;P2=0x0f;delay2();P0=0x00;P1=0x00;P2=0x00;delay2();P0=0xf0;P1=0xf0;P2=0xf0;delay2();P0=0x00;P1=0x00;P2=0x00;delay2();}void delay2(void){uchar i,j,k;for(i=0;i50;i++)for(j=0;j80;j++)for(k=0;k100;k++);}void kaolong(void){P0=0x00;P1=0x00;P2=0x00;P0=0x11;P1=0x81;P2=0x88;delay2();P0=0x22;P1=0x42;P2=0x44;delay2();P0=0x44;P1=0x24;P2=0x22;delay2();P0=0x88;P1=0x18;P2=0x11;delay2();}void liushui2(void){P0=0x00;P1=0x00;P2=0x00;P0=0x01;delay();P0=0x08;delay();P0=0x40;delay();P0=0x00;P1=0x02;delay();P1=0x10;delay();P1=0x80;delay();P1=0x00;P2=0x04;delay();P2=0x20;delay();P2=0x00; //===================red P0=0x02;delay();P0=0x010;delay();P0=0x80;delay();P0=0x00;P1=0x04;delay();P1=0x20;delay();P1=0x00;P2=0x01;delay();P2=0x08;delay();P2=0x40;delay();P2=0x00; //===================greenP0=0x04;delay();P0=0x20;delay();P0=0x00;P1=0x01;delay();P1=0x08;delay();P1=0x40;delay();P1=0x00;P2=0x02;delay();P2=0x10;delay();P2=0x80;delay();P2=0x00; //======================blue }
- SD卡SPI读写子程序以及SD卡设置成SPI总线的操作(11-27)
- 模糊控制算法子程序(11-23)
- 键盘子程序(AVR) (12-09)
- 51单片机中定时器的小程序(03-04)
- 四种基本程序结构(01-07)
- 51单片机通用汇编延时子程序(10-12)