/*-----------------------------------------------
Name: Two-color dot matrix
Forum: www.doflye.net
Written by: shifang
Modification: None
Content: Using hc595 to drive two-color dot matrix
------------------------------------------------*/
#include
#include
//unsigned char segout[8]={0,1,2,3,4,5,6,7}; //8列
unsigned char segout[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //8列
unsigned char code tab[]={
0x08,0x1C,0x3E,0x7F,0x1C,0x1C,0x1C,0x1C,
};
/*------------------------------------------------
Hardware Port Definition
------------------------------------------------*/
sbit LATCH = P1^0;
sbit SRCLK= P1^1;
sbit SER = P1^2;
sbit LATCH_B = P2^2;
sbit SRCLK_B= P2^1;
sbit SER_B= P2^0;
/*------------------------------------------------
uS delay function, with input parameter unsigned char t, no return value
unsigned char is used to define an unsigned character variable, whose value range is
0~255 Here we use a 12M crystal oscillator. Please use assembly for accurate delay. Approximate delay
The length is as follows: T=tx2+5 uS
------------------------------------------------*/
void DelayUs2x(unsigned char t)
{
while(--t);
}
/*------------------------------------------------
mS delay function, with input parameter unsigned char t, no return value
unsigned char is used to define an unsigned character variable, whose value range is
0~255 Here we use a 12M crystal oscillator. Please use assembly code for accurate delay.
------------------------------------------------*/
void DelayMs(unsigned char t)
{
while(t--)
{
//About 1mS delay
DelayUs2x(245);
DelayUs2x(245);
}
}
/*------------------------------------------------
Send Bytes Program
------------------------------------------------*/
void SendByte(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++)
{
SRCLK=0;
SER=that&0x80;
dat<<=1;
SRCLK=1;
}
}
/*------------------------------------------------
Send double byte program
595 cascade, n 595, need to send n bytes and then latch
------------------------------------------------*/
void Send2Byte(unsigned char dat1,unsigned char dat2)
{
SendByte(dat1);
SendByte(dat2);
}
/*------------------------------------------------
595 Latch Program
After 595 cascade sends data, latch is valid
------------------------------------------------*/
void Out595(void)
{
LATCH=1;
_nop_();
LATCH=0;
}
/*------------------------------------------------
Send Bitcode Bytes Program
Use another separate 595
------------------------------------------------*/
void SendSeg(unsigned char dat)
{
unsigned char i;
for(i=0;i<8;i++) //send bytes
{
SRCLK_B=0;
SER_B=dat&0x80;
dat<<=1;
SRCLK_B=1;
}
LATCH_B=1; //Latch
_nop_();
LATCH_B=0;
}
/*------------------------------------------------
Main Program
------------------------------------------------*/
void main()
{
unsigned char i,j,k;
while(1)
{
for(i=0;i<8;i++) //8 columns display
{
SendSeg(segout[i]);
Send2Byte(~tab[i],0xff); //Display arrow graphics at fixed position
Out595();
DelayMs(1);
Send2Byte(0xff,0xff);//delay(10); //Prevent ghosting
Out595();
}
}
}
Previous article:MCU DS18b20 Temperature detection LCD display
Next article:Single chip dual color dot matrix display 1 color
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Jetson Nano Remote Desktop cannot open terminal
- Could you please tell me what this operation of 1602 LCD means and what is its function?
- robot
- The digital signal and noise are not much different (amplitude and frequency). Can software algorithms be used to extract the signal and filter out the noise?
- Recruiting BMS system test engineers Annual salary: 200,000-350,000 | Experience: more than 3 years | Work location: Baoding, Wuxi
- Digital Communication FPGA Development and Design Platform.pdf
- ADI reference material sharing
- EEWORLD University ---- Embedded C Language
- Espressif ESP32-S3-WROOM-2 latest information
- Analog Electronics Popular Data Download Collection