Question Analysis
The main purpose is to connect 8 switches to the extended input port and 8 LEDs to the extended output port. How to control the display of 8 LEDs corresponding to 8 switches?
Other external chips are needed in the experiment
method one
Use 74LS373 and 74LS245 as external chips to complete the experiment
Experimental Circuit Diagram
Experiment Code
#include #include #define uchar unsigned char void delay(unsigned int n) { unsigned int i,j; for(i=0;i ; } flying i; void main(void) { while(1) { i=XBYTE[0x7fff]; //Enter the switch information of the input port into i delay(1); //delay program XBYTE[0x7fff]= i; //Transfer the input switch information to the output address } } The experimental code is not difficult to understand. It is to assign the button information of the input port (address 0x7fff) to i, and then transfer the data of the input port to the output port. The input port is connected to the button, and the output port is connected to the LED light. It is the same as the circuit diagram above. Experimental Results The LED light turns on and off corresponding to each button pressed. Method Two Use 8255 and 74LS373 as external chips to complete the experiment Experimental Circuit Diagram Experiment Code #include #include #define uchar unsigned char flying i; void delay(unsigned int n) { unsigned int i,j; for(i=0;i ; } void main (void) { while(1) { i= 0x90; //optional XBYTE[0xff7fc]= i; //optional i=XBYTE[0xff7c]; //Same as the above program delay(1); //Same as above program XBYTE[0xff7d]= i; //Same as the above program } } Experimental Results The LED light turns on and off corresponding to each button pressed. Summarize The results of the I/O input and output experiment of the microcontroller (AT89C51) peripherals are relatively simple and clear, but it is mainly necessary to understand the experimental principles.
Previous article:The single chip microcomputer (AT89C51) button controls the LED light to realize the running light and flashing running light
Next article:Serial communication experiment of single chip microcomputer (AT89C51)
- 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)
- embOS-Ultra: High-resolution system
- Data flow modeling
- [Top Micro Smart Display Screen Review] 4. Network port remote update and communication function test and questions
- IAR for MSP430 Two methods of adding custom header files
- CC2640R2F supports Alibaba Cloud Link IoT platform
- What are the high-precision and high-reliability renewable energy storage systems?
- [SensorTile.box] Programming mode - Losing to the environment
- [Mill MYB-YT507 development board trial experience] + unboxing experience
- EEWORLD University ---- DXP
- [Evaluation of domestic FPGA Gaoyun GW1N-4 series development board] OLED display