Write: Adam
Time to write: on November 19, 2018
Hardware support: STC12C5A60S2 external 12 MHZ crystal vibration
Interface description:
Modify log:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Description:
Destroy using PWM mode to adjust the LED light cycle, achieve brightness changes,
In scan mode, display Chinese characters, 16 x16 dot,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include
Unsigned char DY_PWM;//each point display time, cooperate with delay procedures,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Sbit DY_LED1_H1=P0 ^ 0;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H2=P0 ^ 1;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H3=P0 ^ 2;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H4=P0 ^ 3;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H5=P0 ^ 4;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H6=P0 ^ 5;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H7=P0 ^ 6;//set the LED lattice screen connected I/O port
Sbit DY_LED1_H8=P0 ^ 7;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H1 P1=^ 0;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H2 P1=^ 1;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H3=p ^ 2;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H4 P1=^ 3;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H5=P1 ^ 4;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H6=P1 ^ 5;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H7=P1 ^ 6;//set the LED lattice screen connected I/O port
Sbit DY_LED2_H8=P1 ^ 7;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L1=P2 ^ 0;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L2=P2 ^ 1;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L3=P2 ^ 2;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L4=P2 ^ 3;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L5=P2 ^ 4;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L6=P2 ^ 5;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L7=P2 ^ 6;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L8=P2 ^ 7;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L9=P3 ^ 0;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L10=P3 ^ 1;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L11=P3 ^ 2;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L12=P3 ^ 3;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L13=P3 ^ 4;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L14=P3 ^ 5;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L15=P3 ^ 6;//set the LED lattice screen connected I/O port
Sbit DY_LED1_L16=P3 ^ 7;//set the LED lattice screen connected I/O port
Sbit DY_BEEP P1=^ 0;//speaker
Sbit DY_18B20=P2 ^ 1;//temperature sensor
Sbit DY_KEY=P2 ^ 2;//button
Sbit DY_POWER=P2 ^ 0;//power monitoring
# define DY_P0M1SET 0 x00//set the I/O port works//00000000
# define DY_P0M0SET 0 XFF//set the I/O port works//11010011
# define DY_P1M1SET 0 x00//set the I/O port works//00000000
# define DY_P1M0SET 0 XFF//set the I/O port works//00101000
# define DY_P2M1SET 0 x00//set the I/O port works//00000000
# define DY_P2M0SET 0 x00//set the I/O port works//01011000
# define DY_P3M1SET 0 x00//set the I/O port works//00000000
# define DY_P3M0SET 0 x00//set the I/O port works//10010100
# define DY_P4M1SET 0 x00//set the I/O port works//00000000
# define DY_P4M0SET 0 x00//set the I/O port works//11100000
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Unsigned char code SPEED []={//show the words "SPEED" called SPEED setting an array from left to right, from top to bottom longitudinal 8 under high
0 x00 to 0 x00 to 0 x00 to 0 x00 to 0 xf8, 0 x07, 0 xf0, 0 x03,
0 x10, 0 x02, 0 x10, 0 x02, 0 x10, 0 x02, 0 XFF, 0 XFF,//"in",
0 xfe, 0 x7f, 0 x10, 0 x02, 0 x10, 0 x02, 0 x10, 0 x02,
X07 0 xf0, 0, 0 xf8, 0 x03, 0 x10, 0 x00 to 0 x00 to 0 x00,
0 x00 to 0 x00 to 0 x00 to 0 x00 to 0 XFF, 0 XFF, 0 xfe, 0 x7f,
X92 0 x02, 0 x50, 0, 0 x50, 0 x92, 0 x50, 0 xf2, 0 x5f,//"kingdom",
X92 xf2 0, 0 x5f, 0, 0 x53, 0 xda, 0 x5e, 0 x92, 0 x54,
X50 0 x02, 0, 0 xfe, 0 XFF, 0 XFF, 0 x7f, 0 x02, 0 x00,
0 x00 to 0 x00 to 0 x00 to 0 x10, 0 x80, 0 x10, 0 x80, 0 x08,
X88 x88 0, 0 x0c, 0, 0, x06 x88 0, 0 x03, 0 XFF, 0 x7f,
Xc8 0 xfe, 0 XFF, 0, 0 xc8, 0 xe8, 0 xc8, 0 xb8, 0 XCC,//"old",
Xc8 x9c 0, 0 xf6, 0, 0 x44, 0 x80, 0 x00 to 0 x00 to 0 x00,
0 x00 to 0 x00 to 0 x00 to 0 x84, 0 x00 to 0 x84, 0 x00 to 0 x44,
X77 0 xfe, 0, 0 XFC, 0 x3f, 0 x24, 0 x14, 0 x24, 0 x04,//"soldier,"
X22 x26 0, 0 x04, 0, 0 x04, 0 xe3, 0 x0f, 0 xe3, 0 x17,
X32 0, 0 x74, 0 x20, 0 xe4, 0 x00 to 0 x46, 0 x00 to 0 x04
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void delay (unsigned int a) {//0.1 ms delay program (12 MHZ 10 times the 51 single-chip microcomputer speed)
Unsigned int I;
While (- a!=0) {
For (I=0; I & lt; 1; I++);
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void dis_off (void) {
P0=~ DY_P0M0SET;//off all show
P1=~ DY_P1M0SET;
The P2=~ DY_P2M0SET;
P3=~ DY_P3M0SET;
P4=~ DY_P4M0SET;
Delay (20 - DY_PWM);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void displayLL1 (unsigned char d, c) {//column 1 horizontal display program
Unsigned char I;
I=d & amp; 0 x01;
If (I==0 x01) {//the first screen 8 column
DY_LED1_H1=1; DY_LED1_L1=0; Delay (DY_PWM); Dis_off (); }
I=d & amp; 0 x02;
If (I==0 x02) {
DY_LED1_H2=1; DY_LED1_L1=0; Delay (DY_PWM); Dis_off (); }
I=d & amp; 0 x04;
If (I==0 x04) {
DY_LED1_H3=1; DY_LED1_L1=0; Delay (DY_PWM); Dis_off (); }
I=d & amp; 0 x08;
If (I==0 x08) {
DY_LED1_H4=1; DY_LED1_L1=0; Delay (DY_PWM); Dis_off (); }
I=d & amp; 0 x10. nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull