Microcontroller C language programming: key control 8X8LED dot matrix screen display graphics

Publisher:RadiantEyesLatest update time:2013-08-31 Source: 21icKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 /* Name: Button control 8X8LED dot matrix display

Graphics

Note: Each time K1 is pressed, 8X8LED

The dot matrix screen displays different graphics in a cycle.

This example uses both external interrupts and timers.

Time interruption.

*/

#include


#include

#define uchar unsigned char

#define uint unsigned int

//Graphic code to be displayed

uchar code M[][8]=

{

{0x00,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x00}, //Figure 1

{0x00,0x38,0x44,0x54,0x44,0x38,0x00,0x00}, //Figure 2

{0x00,0x20,0x30,0x38,0x3c,0x3e,0x00,0x00} //Figure 3

};

uchar i,j;

//Main program

void main()

{

P0=0xff;

P1=0xff;  

 

TMOD=0x01; //T0 mode 1

 

TH0=(65536-2000)/256; //2ms timing

TL0=(65536-2000)%256;

 

 

 

 

IT0=1; //Falling edge trigger

IE=0x83; //Enable timer 0 and external 0 interrupts

i=0xff; //The initial value of i is set to 0xff, and it will start from 0 after adding 1

while(1);

}[page]

//T0 interrupt controls the dot matrix screen display

void Show_Dot_Matrix() interrupt 1

{

TH0=(65536-2000)/256; //Restore initial value

TL0=(65536-2000)%256;

 

 

 

 

P0=0xff; //Output bit code and segment code

P0=~M[i][j];

P1=_crol_(P1,1);

j=(j+1)%8;

}


//INT0 interrupt (timer is started by keyboard interrupt)

void Key_Down() interrupt 0

{

P0=0xff;

P1=0x80;

j=0;

 

 


i=(i+1)%3; //i takes values ​​from 0, 1, 2, because only 3 graphics are needed

TR0=1;

}

Microcontroller C language programming: key control 8X8LED dot matrix screen display graphics

 

Keywords:MCU Reference address:Microcontroller C language programming: key control 8X8LED dot matrix screen display graphics

Previous article:Microcontroller C language programming: doorbell designed with timer
Next article:Microcontroller C language programming: 8X8LED dot matrix display digital

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号