MCU: STC12C56 Crystal: 12MHZ *************************************/ #include#include #define uchar unsigned char #define uint unsigned int #define RGB_count 20 #define RGB_speed 30 sbit DIN=P1^2; /*************0 code***********************/ void DIN_bit_0() { flying i; DIN=1; for(i=1;i>0;i--); //Low speed mode 1+3+4*3+1 _nop_(); DIN=0; //1+3+4*7 for(i=3;i>0;i--); } /*************1 code********************/ void DIN_bit_1() { flying i; DIN=1; //1+3+4*7+1 for(i=3;i>0;i--); _nop_(); DIN=0; for(i=1;i>0;i--); //1+3+4*3 } /*************reset code***********************/ void reset() { uint i; DIN=0; for(i=250;i>0;i--); } /*************data transmission******************/ void send_dat(uchar dat) //high bit first { flying i; for(i=8;i>0;i--) { if(dat & 0x80) DIN_bit_1(); else DIN_bit_0(); dat <<=1; } } /***************Delay******************/ void delay(uchar t) { unsigned long j; while(t--) for(j=0;j<1000;j++); } /*************Main program******************/ void main() { uchar i,n,num,t; while(1) { /*************R gradually brightens********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(0); send_dat(0); } reset(); delay(1); } /*************R gradually disappears***********************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(0); send_dat(0); } reset(); delay(1); } /****************G gradually brightens********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(i); send_dat(0); } reset(); delay(1); } /****************G gradually disappears********************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(i); send_dat(0); } reset(); delay(1); } /****************B gradually brightens********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(0); send_dat(i); } reset(); delay(1); } /************B gradually disappears********************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(0); send_dat(i); } reset(); delay(1); } /*************RG gradually brightens********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(i); send_dat(0); } reset(); delay(1); } /*************RG gradually disappears***********************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(i); send_dat(0); } reset(); delay(1); } /*************GB gradually brightens***********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(i); send_dat(i); } reset(); delay(1); } /*************GB gradually disappears*******************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(0); send_dat(i); send_dat(i); } reset(); delay(1); } /*************RB gradually brightens***********************/ for(i=0;i<255;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(0); send_dat(i); } reset(); delay(1); } /*************RB gradually disappears*******************/ for(i=255;i>0;i++) { for(n=RGB_count;n>0;n--) { send_dat(i); send_dat(0); send_dat(i); } reset(); delay(1); } /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); /****************B Marquee Added********************/ for(i=0;i 0;t--) delay(1); } /****************B Marquee reduction********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /****************G Marquee added********************/ for(i=0;i 0;t--) delay(1); } /****************G Marquee reduction********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /*************R Marquee added***********************/ for(i=0;i 0;t--) delay(1); } /*************R Marquee reduction********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /*************RG Marquee Added***********************/ for(i=0;i 0;t--) delay(1); } /*************RG Marquee Reduction***********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /*************GB Marquee Added***********************/ for(i=0;i 0;t--) delay(1); } /*************GB Marquee Reduce********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /*************RB marquee added*******************/ for(i=0;i 0;t--) delay(1); } /*************RB Marquee Reduce***********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } /*************RGB marquee added*******************/ for(i=0;i 0;t--) delay(1); } /*************RGB marquee reduction***********************/ for(i=RGB_count;i>0;i--) { for(num=0;num0;t--) delay(1); /*************RGB all destroyed***********************/ for(num=RGB_count;num>0;num--) { send_dat(0); send_dat(0); send_dat(0); } reset(); } } }
Previous article:The best LED remote controller---adjust without flickering
Next article:Written for those who are about to get in touch with MCU or those who have just gotten in touch with MCU
Recommended ReadingLatest update time:2024-11-16 20:55
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Nios 2 software build tools for eclipse freezes when creating a project
- DC power supply design
- [Qinheng RISC-V core CH582] BUG serial port can only receive up to 8 bytes at a time
- Open Source & Group Purchase: RCSN's Wireless Multi-channel Serial Port Tool is here~
- How to Learn FPGA
- Share a RF power amplifier design guide
- Op amp offset voltage and single or dual power supply issues?
- Keysight Technologies' Thanksgiving Month Oscilloscope Award Photos
- Serial communication, 1-wire, TWI communication, what are the differences between these three communication methods? Who knows about it? Popular...
- How to filter out 50HZ power frequency interference introduced by active filtering