Traditional Culture Encyclopedia - Traditional culture - Singlechip beginners, please give some programming examples (in C language) to the master, and it is best to take notes. Thank you very much
Singlechip beginners, please give some programming examples (in C language) to the master, and it is best to take notes. Thank you very much
# Define uint unsigned integer
# Define uchar unsigned characters
Uchar number;
Uchar code table [] = {
0x28,0x7e,0xa2,0x62,0x74,
0x6 1,0x2 1,0x7a,0x20,0x60,
0x30,0x25,0xA9,0x26,0xa 1,0xb 1 };
Invalid delay (unsigned integer z);
TT uint k;
void main()
{
TMOD = 0x 0 1; //Timer0 setting mode 1
TH0 =(65536-50000)/256;
TL0 =(65535-50000)% 256;
EA = 1; //Open host interrupt
ET0 = 1; //Open Timer 0 interrupt
TR0 = 1; //Timer 0 starts to work.
k = 0;
TT = 0;
P2 = 0x 00;
while( 1)
{
If (tt==20)
{
TT = 0;
P0 = table [k];
k++;
If (k== 16)
k = 0;
p 1 _ 1 = 1;
}
}
}
Void exter0 () interrupt 1
{
p 1 _ 1 = 0;
TH0 =(65536-50000)/256;
TL0 =(65535-50000)% 256;
TT ++;
}
I wrote the timer basic program myself.
And interrupt the basic program.
# include & ltAT89X5 1。 H & gt
# Define uint unsigned integer
# Define uchar unsigned characters
Uchar number;
Uchar code table [] = {
0x28,0x7e,0xa2,0x62,0x74,
0x6 1,0x2 1,0x7a,0x20,0x60,
0x30,0x25,0xA9,0x26,0xa 1,0xb 1 };
Invalid delay (unsigned integer z);
uint k;
void main()
{
P2 = 0x 00;
while( 1)
{
for(k = 0; k & lt 16; k++)
{
P0 = table [k];
Delay (200);
}
}
}
Void delay(unsigned int z) // delay function, where the value of z is the delay number of this function, such as delay (200); The delay is about 200 milliseconds.
{//delay (500); The delay is about 500 milliseconds.
Unsigned integers x, y;
for(x = z; x & gt0; x -)
for(y = 1 10; y & gt0; y-);
}
Is it okay?
- Previous article:Brief introduction of modern biathlon
- Next article:What is the difference between balsamic vinegar, aged vinegar and aged vinegar?
- Related articles
- What food does Tomb-Sweeping Day eat? What food does Tomb-Sweeping Day eat?
- Singapore's traditional culture
- Digital Camera
- Marketing planning of hotel meeting room
- Henan cuisine "fried meat box" practice step-by-step chart, how to do delicious
- Knowledge of photography structure for beginners.
- What are the characteristics of Suzhou folk houses?
- Comparison between Shouguang Houde School and Overseas Chinese School
- What powers does Batman have?
- Etiquette requirements for entertaining guests in China