九齐数码管显示A-Z

[复制链接]
172|0
手机看帖
扫描二维码
随时随地手机跟帖
34af9uc|  楼主 | 2022-8-21 22:03 | 显示全部楼层 |阅读模式
/****************九齐NY8BM72AS20*******************/
/****************快手:共同学习stm8*****************/
/****************QQ:774145445**********************/
/****************20220814**************************/
/**************************************************/
//             __NY8BM72AS20__
//          1 |VSS   \_/   VDD|20
//          2 |PA6         PA4|19
//          3 |PA7         PA3|18
//          4 |PA5/VPP     PA2|17
//          5 |PB3         PA1|16
//          6 |PB2         PA0|15
//          7 |PB1         PB5|14
//          8 |PB0         PB4|13
//          9 |PC0/SDA     PB6|12
//          10|PC1/SCL_____PB7|11
/**************************************************/
//    LD-561B
//  @10@9@8@7@6     //   ____________DIG________________
//  _____a____      // _|_ _|_ _|_ _|_ _|_ _|_ _|_ _|_  |
// |          |     // \|/ \|/ \|/ \|/ \|/ \|/ \|/ \|/  |
// f          b     //  |   |   |   |   |   |   |   |   |
// |_____g____|     //  a   b   c   d   e   f   g   h  3,8
// |          |     //  7   6   4   2   1   9  10   5   |
// e          c     //  |   |   |   |   |   |   |   |   |
// |____d_____| .h  //  16  15  5   3   2  18  20   6   17
//  @1@2@3@4@5      // PA1 PA0 PB3 PA7 PA6 PA3 PA4 PB2 PA2
/**************************************************/
#include <ny8.h>
#include "ny8_constant.h"
/**************************************************/
unsigned char const zi1[]={ 0xfc,0x60,0xda,0xf2,0x66,
0xb6,0xbe,0xe0,0xfe,0xf6,0x7e};//0-20
unsigned char const zi2[]={ 0xee,0x3e,0x9c,0x7a,0x9e,
0x8e,0xf6,0x6e,0x20,0x78,0x1e,0x1c,0xcc,0x2a,0x3a,0xce,
0xe6,0x0a,0xb6,0x1e,0x7c,0x38,0x3c,0x6e,0x76,0xda};//0a-z
/**************************************************/
__sbit led_a                =PORTA : 1;
__sbit led_b                =PORTA : 0;
__sbit led_c                =PORTB : 3;
__sbit led_d                =PORTA : 7;
__sbit led_e                =PORTA : 6;
__sbit led_f                =PORTA : 3;
__sbit led_g                =PORTA : 4;
__sbit led_h                =PORTB : 2;
__sbit led_dig                =PORTA : 2;
__sbit anjian1                =PORTB : 6;
/**************************************************/
void                yanshi(int);
void                anjian();                //按键
void                xianshi();                //显示
/**************************************************/
unsigned char xian_a1;
unsigned char a1;
/**************************************************/
void main(void)
{

IOSTA        &=~((1<<1)+(1<<0)+(1<<7)+(1<<6)+(1<<3)+(1<<4)+(1<<2));                //0输出1输入
IOSTB        &=~((1<<3)+(1<<2));

IOSTB                &=~(1<<7);
PB7                        =0;                                //输出0按键用
IOSTB                |=(1<<6);
//BPHCON                &=~(1<<6);                //上拉电阻0启用,1禁用
PHPB6=0;

/**************************************************/
led_dig=1;                                //LED公共端(共阳)
a1=0;
while(1)
{
anjian();
xian_a1=zi2[a1];
//xian_a1=zi1[a1];
xianshi();
led_h=1;
yanshi(10000);
led_h=0;
yanshi(10000);


}
}
/**************************************************/
void yanshi(int count)
{
        int i;
        for(i=1;i<=count;i++);
}
/**************************************************/
void                xianshi()                //显示
{
if(xian_a1&0x80){led_a=0;}        else {led_a=1;}
if(xian_a1&0x40){led_b=0;}        else {led_b=1;}
if(xian_a1&0x20){led_c=0;}        else {led_c=1;}
if(xian_a1&0x10){led_d=0;}        else {led_d=1;}

if(xian_a1&0x08){led_e=0;}        else {led_e=1;}
if(xian_a1&0x04){led_f=0;}        else {led_f=1;}
if(xian_a1&0x02){led_g=0;}        else {led_g=1;}
if(xian_a1&0x01){led_h=0;}        else {led_h=1;}
}
/**************************************************/
void                anjian()                //按键
{
if(anjian1==0)

        {
        a1++; if(a1==26){a1=0;}
        }


}
/**************************************************/
/**************************************************/

main.zip

1.27 KB

使用特权

评论回复
发新帖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

273

主题

430

帖子

55

粉丝