First put the circuit diagram, pay attention to the selection of capacitors on both sides of the crystal oscillator, and pay attention to the resistance value between the LED and the voltage.
The program is: Note that you must include the pic.h file, you must first determine the size of _XTAL_FREQ before using the __delay_ms macro, and pay attention to the magical effect of LED=~LED.
/*
Function: Make the LED flash at a certain time interval
*/
#include #define _XTAL_FREQ 4000000UL //Oscillator frequency #define LED RC5 //Because the LED light is connected to the RC5 pin void main() { TRISC = 0x00; //Set all PORTC to output PORTC = 0xff; //Set the output of PORTC to 1 while(1) { LED=~LED; // Wonderful, one sentence realizes the flashing of the light. In the past, when I wrote it myself, I had to write it to turn on first, then delay, then turn it off, and then delay again. Here, one sentence solves it. __delay_ms(150); //This delay function is defined in the pic.h file. Before using it, you must first set the size of _XTAL_FREQ, the unit is Hz } }
Previous article:PIC microcontroller i2c program
Next article:PIC microcontroller learning independent buttons
- Popular Resources
- Popular amplifiers
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Live streaming portal now open | TI IoT display solution using DLP micro-projection technology
- Disassembling the sonic motor of an electric toothbrush
- Power supply design parameters
- A netizen asked me if there is a chip that can turn the machine on and off by long pressing.
- Nordic nRF52832 program download problem analysis
- What is the GPIO number under Sys/class?
- Good thing to share: MobIR Air ultra-high cost-effective portable mobile thermal imager
- How to generate .lib file for atmel atudio and call it in other projects
- LPC1768 UCOSII is ported to IAR8.3 environment. There is no problem in compiling, but it is stuck when creating the first task function...
- This module can meet the "high current" required for 3C lithium battery pack testing. You should know about it?