ATmega8535L Marquee Program
//*********************ICCAVR V6.30 compilation**********************//
#include
#define uchar unsigned char //Data type description
#define uint unsigned int //Data type descriptionvoid
DelayMs(uint i) //Ms level delay function, parameter i: delay time
{uint j;
for(;i!=0;i--)
{for(j=8000;j!=0;j--) ;}
}
void Horse(uchar i) //Marquee program, light up the corresponding LED through step judgment
{switch(i) //High level lights up the LED
{case 1:PORTA=0x01;break; //0000 0001B lights up LED1
case 2:PORTA=0x03;break; //0000 0011B lights up LED1~LED2
case 3:PORTA=0x07;break; //0000 0111B lights up LED1~LED3
case 4:PORTA=0x0f;break; //0000 1111B Light up LED1~LED4
case 5:PORTA=0x1f;break; //0001 1111B Light up LED1~LED5
case 6:PORTA=0x3f;break; //0011 1111B Light up LED1~LED6
case 7:PORTA=0x7f;break; //0111 1111B Light up LED1~LED7
case 8:PORTA=0xff;break; //1111 1111B Light up LED1~LED8
default:break;}
}
void main(void)
{uchar i;
DDRA=0xff; //Port setting: PA port is set to push-pull 1 output
PORTA=0xff;
PORTA=0x00; //PORTA initial value is 0, turn off all LEDs
DelayMs(1000);
while(1) //Program is executed unconditionally
{ for(i=0;i<9;i++) //Light up LED1~LED8 in sequence
{Horse(i);
DelayMs(1000);} //Lighting time is about 1 second
for(i=7;i!=0;i--) //Turn off LED8~LED1 in sequence
{Horse(i);
DelayMs(1000);} //Turn off time is about 1 second
}
}
Previous article:AVR MCU bus voice announcement system program
Next article:ATmega8535L Eeprom Example Program
- 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
- EEWORLD University Hall----Prevent machine failures before they happen with CbM status monitoring to help you!
- How does the phase difference between capacitors and inductors occur?
- Motor Testing Discussion
- [RVB2601 Creative Application Development] Create an Any MP3 Player on the Internet
- Raspberry Pi Windows IoT Development (Part 1)
- Can anyone crack it? I have a network speed of tens of G and tens of kilobytes. Even if I climb over the firewall, it won't work.
- [HC32F460 Development Board Review] 03. Implementing SHELL transplantation and control based on UART function
- Detailed explanation of ADC in STM32
- The working principle of the automobile gateway system and the location of the gateway for some models
- MSP430 FRAM Microcontrollers Enable Energy Harvesting