/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
#include <ny8.h>
// NY8BE62D_S16
// _______ _______
// |1 vdd \_/ vss 16|
// |2 pa6 pa4 15|-scl
// |3 pa7 pa3 14|
// |4 pa5 pa2 13|-sda
// |5 pb3 pa1 12|
// led_4-|6 pb2 pa0 11|-led_1
// led_5-|7 pb1 pb5 10|-led_2
// led_6-|8_pb0______pb4__9|-led_3
// LCD CS3631AW-4-D
// @1@2@3@4@5@6
// ___A1___ ___A2___ ___A3___
// F1 B1 F2 B2 F3 B3
// |___G1___| |___G2___| |___G3___|
// E1 C1 DP E2 C2 DP E3 C3 DP
// |___D1___|. |___D2___|. |___D3___|.
// x_a1 x_a2 x_a3 //全局变量
// 1 1 4 5 1 2 3 1 2 2 5 2 2 3 4 3 5 3 4 6 6 4 5 4
// | | | | | | | | | | | | | | | | | | | | | | | |
/* /|\/|\/|\/|\/|\/|\/|\/|\ /|\/|\/|\/|\/|\/|\/|\/|\ /|\/|\/|\/|\/|\/|\/|\/|\*/
// | | | | | | | | | | | | | | | | | | | | | | | |
// 2 3 1 1 4 1 1 6 3 4 2 6 5 2 2 6 4 5 5 1 3 3 3 6
// A1 B1 C1 D1 E1 F1 G1 DP A2 B2 C2 D2 E2 F2 G2 DP A3 B3 C3 D3 E3 F3 G3 DP
/**************************************************/
__sbit led_1 =PORTA:0;
__sbit led_2 =PORTB:5;
__sbit led_3 =PORTB:4;
__sbit led_4 =PORTB:2;
__sbit led_5 =PORTB:1;
__sbit led_6 =PORTB:0;
/**************************************************/ //0输出1输入
#define led_1_h IOSTA&=~(1<<0);led_1=1
#define led_2_h IOSTB&=~(1<<5);led_2=1
#define led_3_h IOSTB&=~(1<<4);led_3=1
#define led_4_h IOSTB&=~(1<<2);led_4=1
#define led_5_h IOSTB&=~(1<<1);led_5=1
#define led_6_h IOSTB&=~(1<<0);led_6=1
#define led_1_l IOSTA&=~(1<<0);led_1=0
#define led_2_l IOSTB&=~(1<<5);led_2=0
#define led_3_l IOSTB&=~(1<<4);led_3=0
#define led_4_l IOSTB&=~(1<<2);led_4=0
#define led_5_l IOSTB&=~(1<<1);led_5=0
#define led_6_l IOSTB&=~(1<<0);led_6=0
#define led_1_g IOSTA|=1<<0
#define led_2_g IOSTB|=1<<5
#define led_3_g IOSTB|=1<<4
#define led_4_g IOSTB|=1<<2
#define led_5_g IOSTB|=1<<1
#define led_6_g IOSTB|=1<<0
/**************************************************/
void yanshi(unsigned int x);
void xianshi(); //显示
unsigned char x_a1,x_a2,x_a3; //全局变量显示用
/**************************************************/
unsigned char const zi1[]={ 0xfc,0x60,0xda,0xf2,0x66,
0xb6,0xbe,0xe0,0xfe,0xf6,0x7e};//0-20
/**************************************************/
void main(void)
{
x_a1 =zi1[0];
x_a2 =zi1[1];
x_a3 =zi1[2];
while(1)
{
xianshi();
}
}
/**************************************************/
void yanshi(unsigned int x)
{
unsigned int y;
{
for(y=1;y>0;y--);
}
}
/**************************************************/
void xianshi() //显示
{
//unsigned char x_a1,x_a2,x_a3; //全局变量显示用
led_1_h; //第一次扫描
if(x_a1&0x20){led_4_l;} else{led_4_g;}
if(x_a1&0x10){led_5_l;} else{led_5_g;}
if(x_a1&0x04){led_2_l;} else{led_2_g;}
if(x_a1&0x02){led_3_l;} else{led_3_g;}
if(x_a3&0x10){led_6_l;} else{led_6_g;}
yanshi(10);
led_1_g;
led_2_h; //第二次扫描
if(x_a1&0x80){led_1_l;} else{led_1_g;}
if(x_a2&0x20){led_5_l;} else{led_5_g;}
if(x_a2&0x04){led_3_l;} else{led_3_g;}
if(x_a2&0x02){led_4_l;} else{led_4_g;}
yanshi(10);
led_2_g;
led_3_h; //第三次扫描
if(x_a1&0x40){led_1_l;} else{led_1_g;}
if(x_a2&0x80){led_2_l;} else{led_2_g;}
if(x_a3&0x08){led_6_l;} else{led_6_g;}
if(x_a3&0x04){led_4_l;} else{led_4_g;}
if(x_a3&0x02){led_5_l;} else{led_5_g;}
yanshi(10);
led_3_g;
led_4_h; //第四次扫描
if(x_a1&0x08){led_1_l;} else{led_1_g;}
if(x_a2&0x40){led_2_l;} else{led_2_g;}
if(x_a3&0x80){led_5_l;} else{led_5_g;}
yanshi(10);
led_4_g;
led_5_h; //第五次扫描
if(x_a2&0x08){led_2_l;} else{led_2_g;}
if(x_a3&0x40){led_3_l;} else{led_3_g;}
if(x_a3&0x20){led_4_l;} else{led_4_g;}
yanshi(10);
led_5_g;
led_6_h; //第六次扫描
if(x_a1&0x01){led_1_l;} else{led_1_g;}
if(x_a2&0x10){led_2_l;} else{led_2_g;}
if(x_a2&0x01){led_3_l;} else{led_3_g;}
if(x_a3&0x01){led_4_l;} else{led_4_g;}
yanshi(10);
led_6_g;
}
/**************************************************/
/**************************************************/
/**************************************************/
|