51 single chip microcomputer 8X8 dot matrix screen circularly moves left

Publisher:冷漠之心Latest update time:2022-01-12 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Use timer 0 interrupt to control 8x8 dot matrix screen to shift left in a loop


#include

#include

typedef unsigned char u8;

typedef unsigned int u16;

 

sbit SRCLK=P3^6;

sbit RCLK=P3^5;

sbit SER=P3^4;

 

u16 i,k;

u16 time;

  

u8 code ledduan[][8]={{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24},     

                      {0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x6c},    

                      {0x00,0x00,0x00,0x00,0x00,0x24,0x6c,0xff},    

                      {0x00,0x00,0x00,0x00,0x24,0x6c,0xff,0xff}, 

                      {0x00,0x00,0x00,0x24,0x6c,0xff,0xff,0x6c},    

                      {0x00,0x00,0x24,0x6c,0xff,0xff,0x6c,0x24},     

                      {0x00,0x24,0x6c,0xff,0xff,0x6c,0x24,0x00},     

                    {0x24,0x6c,0xff,0xff,0x6c,0x24,0x00,0x00},

                      {0x6c,0xff,0xff,0x6c,0x24,0x00,0x00,0x00},

                      {0xff,0xff,0x6c,0x24,0x00,0x00,0x00,0x00},

{0xff,0x6c,0x24,0x00,0x00,0x00,0x00,0x00},

{0x6c,0x24,0x00,0x00,0x00,0x00,0x00,0x00},

{0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00},};

 

 

u8 code ledwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};

 

void delay(u16 i)

{

while(i--);

}

 

void timer0init()

{

TMOD=0x01;

TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

ET0=1;

TR0=1;

EA=1;

}

 

void Hc595SendByte(u8 dat)

{

u8a;

SRCLK=0;

RCLK=0;

for(a=0;a<8;a++)

{

SER=dat>>7;

dat<<=1;

SRCLK=1;

_nop_();

_nop_();

SRCLK=0;

}

RCLK=1;

_nop_();

_nop_();

RCLK=0;

}

 

void main()

{

timer0init();

{

while(1)

{

for(i=0;i<8;i++)

{

  P0=ledwei[i];

  Hc595SendByte(ledduan[k][i]);

  delay(50);

  Hc595SendByte(0x00);

}

}

}

}

 

void timer0() interrupt 1

{

TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

time++;

{

if(time>=5)

{

k++;

time=0;

}

if(k>12)

{

k=0;

}

}

}

Reference address:51 single chip microcomputer 8X8 dot matrix screen circularly moves left

Previous article:51 single chip microcomputer project design: ultrasonic-based garage parking system and parking space detection
Next article:51 MCU external interrupt 0 controls the LED on and off

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号