Development board schematic diagram:
From the schematic diagram of the development board, we know that LEDs 1 to 8 are connected to P2^0 to P2^7 respectively. When low voltage is input to P2 port, the LED lights up (VCC indicates high voltage, and P2 outputs low voltage when it is 0 and high voltage when it is 1).
It can be expressed in two ways:
1.
#include sbit led1=P2^0; //If you want to use other LEDs, change to the corresponding void main() { led1=0; } #include #define led P2 //no semicolon void main() { led=0x00; //0x means hexadecimal, other explanations are below } Note: P is capitalized. Here is the code I wrote: #include "reg52.h " #include "intrins.h" #define led P2 //#define is a macro definition void delay(unsigned int i) //custom delay function { while(i--); } void main() { unsigned int i=0; //define unsigned integer i and assign value 0 led=0xfe; //0xfe is hexadecimal: 1111 1110; that is, only the first LED is lit delay(20000); //Call the delay function above to achieve the purpose of delay while(i<7) //while loop, when i does not meet the condition, {} the inner loop ends { led=_crol_(led,1); //Left shift function: LED is shifted left by 1 bit, that is, 1111 1101, which can light up the second LED delay(20000); i++; //i=i+1; } //The above while loop can make the eight LEDs light up in sequence while(i>2) { led=0x55; //0101 0101 delay(5000); led=~led; //negate: 1010 1010 delay(5000); i--; } } Next, Xiaobai self-studies C51's mood chapter: So damn excited, just a little bit away from ascending to heaven
Previous article:Xiaobai's self-study notes on C51 digital tube 1——D74HC245 and D74HC138
Next article:51 single chip multi-channel independent key switch program
Recommended posts
- 02.USART routines and tests
- ThereisnotmuchinformationaboutL233CxProjectsunderthedevelopmentboardDemo,soUSARTisselectedfortesting. OpentheUSARTrelatedprogram,compileanddownloadit,andthenburnitintothechip BecauseIonlyhaveoneMini
- unisqhzgok GD32 MCU
- Is there any recommended equipment for measuring high voltage and current in automobiles?
- Isthereanyrecommendedequipmentformeasuringhighvoltageandcurrentinautomobiles? Whataretherequirements?Ihavejuststartedtogetinvolvedintheautomotiveelectronicsindustryandhavenotencounteredsuchademandyet.Iamnots
- 是广州智维的段工呀 Automotive Electronics
- Which shielding effect is better, copper foil or plain cloth?
- IwanttoshieldthecircuitonaPCB.Whichoneisbetter,copperfoiltapeorplainclothtapeofthesamethickness? IhaveonlyusedcopperfoiltapeandEMCgluetoenhancetheshieldingofmetalcasings,andbothhaveacertaineffect. Cop
- littleshrimp Integrated technical exchanges
- Dual-band transceiver for 1.3GHz and 2.3GHz bands
- Thisisalowpowerdualbandtransceiverdesignedforthe1.3GHzand2.3GHzamateurbands,operatinginbothSSBandCWmodes.Thefrequenciescoveredare1296MHzto1298MHzand2320MHzto2322MHz. Schematicdiagram
- btty038 RF/Wirelessly
- How to record and call script files in Allegro software?
- Title:HowtorecordandcallscriptfilesinAllegrosoftware? Inthepreviousquestionandanswer,wementionedhowtousetheReplaycommandtospecifyshortcutkeys.WhenusingtheReplaycommandtospecifyshortcutkeys,youneedtorecorda
- 凡亿教育 PCB Design
- Detailed explanation of PWM control principle and circuit application
- 1 PWM(PulseWidthModulation)isatechnologythatusespulsestooutputanalogsignals.Itmodulatesthewidthofaseriesofpulsestoproduceanequivalenttargetwaveform.Itiswidelyusedinmeasurement,communication,switchingpowersuppl
- smls_小森 Power technology
- Popular Resources
- Popular amplifiers
- Principle and application of super-directivity of sensor array (Yang Yixin et al.)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- USB to TTL serial port debugging tool based on 2.4G wireless transmission
- When the epidemic in Shanghai is over, I plan to develop in other cities.
- Power Supply Design Considerations
- Weekly review information is here~
- Learning Linux kernel semaphores on SinlinxA33 development board
- STM32 encoder signal interference.
- [GD32L233C-START Evaluation] +ADC collects PT1000 to obtain temperature
- Three traditional methods of wireless video transmission
- Essential for EMC Electronic Engineers
- Can you help me take a look at this FPGA development board?