Example of use:
/****************************************************** ******************************
* Jumper connection: short-circuit P2 2 and 3
* Function description: Passive buzzer sound
*************************************************** *******************************/
#include #include #define uint8 unsigned char #define uint16 unsigned int __CONFIG(WDTDIS & LVPDIS & HS & PWRTDIS & BORDIS); //Set configuration bits //WDTDIS:disable watchdog timer //LVPDIS: low voltage programming disabled //HS:high speed crystal/resonator //PWRTDIS:disable power up timer //BORDIS:disable brown out reset /***************************Declare function*******************************************/ void DelayUS(uint8 delay); /****************************************************** ****************************** * Function name: DelayUS(uint8 delay) * Function: microsecond delay for 20MHZ * Input parameter: delay * Return: None *************************************************** *******************************/ void DelayUS(uint8 delay) { while(--delay); } /****************************************************** ***************************** * Function name: main(void) * Function: drive the passive buzzer to sound * Input parameters: None * Return: None *************************************************** *******************************/ void main(void) { ADCON1 = 0x86; //PORTA is set as digital IO port TRISA0 = 0; //RA0 is set to output mode while(1) { RA0 = 1; DelayUS(400); RA0 = 0; DelayUS(400); } }
Previous article:PIC Microcontroller - Relay Usage Example
Next article:PIC microcontroller-RS232 serial communication
Recommended ReadingLatest update time:2024-11-15 17:25
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- Teach you to learn 51 single chip microcomputer-C language version (Second Edition) (Song Xuefeng)
- Hand-drawn illustrations revealing the secrets of communication circuits and sensor circuits (Mims III)
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
- 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)
- Learn ARM development(15)
- Getting Started Using TouchGFX to Develop STM32 Interface Applications (Part 1) - Software Installation and Hello World
- psoc creator soft imitation function
- Developer Case: Design of Smart Agriculture Based on Gizwits IoT and RT-Thread
- Basic Theory of System Timing
- GD32L233C-START evaluation development environment construction and official DEMO download test
- Several technical principles of unlocking shared bicycles with mobile phones,,,
- 【GD32E503 Review】——04.MCU CoreMark Performance Test
- [RTT & Renesas high performance CPK-RA6M4] 3. PWM to achieve breathing light evaluation
- Comparison of IIC data and logic diagram between the reference prototype and your own product
- MicroPython Newsletter Issue 6