本帖最后由 神剑无敌 于 2012-3-14 17:12 编辑
接收机现在单独可以正常显示 求甲机能够控制已机显示的甲乙两机的程序。
由于
电路连接特殊,不是正常的IO口顺序连接,我不会用数组方式。
接收机单机程序:
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
/*程序设置完成 可以根据设定进行闪亮 */
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
sbit P13 = P1^3;
sbit P14 = P1^4;
sbit P15 = P1^5;
sbit P16 = P1^6;
sbit P17 = P1^7;
sbit P30 = P3^0;
sbit P31 = P3^1;
sbit P35 = P3^5;
sbit P36 = P3^6;
sbit P37 = P3^7;
sbit P20 = P2^0;
sbit P21 = P2^1;
sbit P22 = P2^2;
sbit P23 = P2^3;
sbit P24 = P2^4;
sbit P25 = P2^5;
sbit P26 = P2^6;
sbit P27 = P2^7;
//声明子函数
void hong();
void lv();
void lan();
void quanliang();
void sansezuizhu();
void honglvzuizhu();
void honglanzuizhu();
void lanlvzuizhu();
void sansejianmie();
void delay(int t)//延时函数
{
unsigned char i,j,k;
for(i=t;i>0;i--) //将原来的i=1 修改为变量t以便以后修改时间常量//
for(j=200;j>0;j--)
for(k=249;k>0;k--); //晶振为24m时 数值249为50ms延时
}
void main()
{
while(8)
{
P1=0;P3=0;P2=0; //初始化 清屏
quanliang(); //全亮
delay(10);
hong(); //顺序点亮
delay(10);
lv();
delay(10);
lan();
delay(10);
sansejianmie(); //三 {MOD}渐灭
delay(10);
sansezuizhu(); //三 {MOD}追逐
delay(10);
sansejianmie(); //三 {MOD}渐灭
delay(10);
honglvzuizhu();
delay(10);
sansejianmie(); //三 {MOD}渐灭
delay(10);
honglanzuizhu();
delay(10);
sansejianmie(); //三 {MOD}渐灭
delay(10);
lanlvzuizhu();
delay(10);
sansejianmie(); //三 {MOD}渐灭
delay(10);
}
}
void hong() //顺序点亮红 {MOD} 绿 {MOD} 蓝 {MOD}
{
P16 = 1; // 红 {MOD}点亮 数值20时为 50ms乘以20次 延时时间为1s //
delay(8);
P17 = 1;
delay(8);
P35 = 1;
delay(8);
P37 = 1;
delay(8);
P11 = 1;
delay(8);
P13 = 1;
delay(8);
}
void lv()
{
P23 = 1; //绿 {MOD}点亮
delay(8);
P20 = 1;
delay(8);
P24 = 1;
delay(8);
P27 = 1;
delay(8);
P10 = 1;
delay(8);
P15 = 1;
delay(8);
}
void lan()
{
P22 = 1; //蓝 {MOD}点亮
delay(8);
P21 = 1;
delay(8);
P25 = 1;
delay(8);
P26 = 1;
delay(8);
P12 = 1;
delay(8);
P14 = 1;
delay(8);
}
void quanliang() //全亮
{
P1 = 0x00; //三 {MOD}全部灭
P3 = 0x00;
P2 = 0x00;
delay(30);
P1 = 0xff; //三 {MOD}全部亮
P3 = 0xff;
P2 = 0xff;
delay(80);
P1 = 0x00; //三 {MOD}全部灭
P3 = 0x00;
P2 = 0x00;
delay(30);
}
void sansezuizhu() //红绿蓝三 {MOD}追逐
{
P16 = 1;
P23 = 1;
P22 = 1;
delay(8);
P17 = 1;
P20 = 1;
P21 = 1;
delay(8);
P35 = 1;
P24 = 1;
P25 = 1;
delay(8);
P37 = 1;
P27 = 1;
P26 = 1;
delay(8);
P11 = 1;
P10 = 1;
P12 = 1;
delay(8);
P13 = 1;
P15 = 1;
P14 = 1;
delay(8);
}
void honglvzuizhu() //红绿追逐
{
P16 = 1;
P23 = 1;
delay(8);
P17 = 1;
P20 = 1;
delay(8);
P35 = 1;
P24 = 1;
delay(8);
P37 = 1;
P27 = 1;
delay(8);
P11 = 1;
P10 = 1;
delay(8);
P13 = 1;
P15 = 1;
delay(8);
}
void honglanzuizhu() //红蓝追逐
{
P16 = 1;
P22 = 1;
delay(8);
P17 = 1;
P21 = 1;
delay(8);
P35 = 1;
P25 = 1;
delay(8);
P37 = 1;
P26 = 1;
delay(8);
P11 = 1;
P12 = 1;
delay(8);
P13 = 1;
P14 = 1;
delay(8);
}
void lanlvzuizhu() //蓝绿
{
P23 = 1;
P22 = 1;
delay(8);
P20 = 1;
P21 = 1;
delay(8);
P24 = 1;
P25 = 1;
delay(8);
P27 = 1;
P26 = 1;
delay(8);
P10 = 1;
P12 = 1;
delay(8);
P15 = 1;
P14 = 1;
delay(8);
}
void sansejianmie() //三 {MOD}渐灭
{
P16 = 0;
P23 = 0;
P22 = 0;
delay(8);
P17 = 0;
P20 = 0;
P21 = 0;
delay(8);
P35 = 0;
P24 = 0;
P25 = 0;
delay(8);
P37 = 0;
P27 = 0;
P26 = 0;
delay(8);
P11 = 0;
P10 = 0;
P12 = 0;
delay(8);
P13 = 0;
P15 = 0;
P14 = 0;
delay(8);
}
一周热门 更多>