This is a program to light up the LEDs one by one. It uses the WIN-GCC compiler. #include#include #define F_CPU 7372800 /* The main frequency of the MCU is 7.3728MHz, used for the delay subroutine*/ #include #include #define delay_us(x) _delay_us(x) //AVR GCC delay function x(us) #define delay_ms(x) _delay_ms(x) //AVR GCC delay function x(ms) void main() { PORTA=0xff; //Close the digital tube port to avoid garbled characters on the digital tube PORTB=0xfe; //Set the output value of port PB DDRB=0xFF; //Define PB port as output mode unsigned char i; while(1) { i=PORTB; for(i=0;i<8;i++) { PORTB=PORTB<<1; delay_ms(500); } PORTB=0xff; delay_ms(500); } }
Previous article:Design of digital frequency meter based on single chip microcomputer
Next article:AVR learning air conditioner infrared remote control code
Recommended ReadingLatest update time:2024-11-16 18:03
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- Share the common problems of MSP430: LCD display driver
- Analysis of common defects, hazards and causes of circuit board welding
- Network port with a speed of 5G or above
- The origin of the BUCK circuit, with three evolutionary circuits
- DSP Learning (1) Introduction to Digital Signal Processors (DSPs)
- Espressif's ESP32-C3 is an extremely low-power SoC equipped with a RISC-V 32-bit single-core processor
- Please teach me a resistance measurement circuit
- Why does the STACK MODE of almost all pads in ALTIUM DESIGNER change to FULL STACK?
- 【STM32WB55 Review】——by Beifang
- 8 principles to follow in PCB stackup design