The two-color car light GP2 made by PIC10F202 is used for switch detection. GP0 and GP1 control two LEDs respectively. When powered on, the GP0 pure white lamp bead lights up. When the switch is powered off once, it switches to the GP1 warm white lamp bead. When the switch is powered off again, it flashes alternately.
The microcontroller source program is as follows:
#include __CONFIG(0X010); #define uchar unsigned char #define uint unsigned int #define TIME_MAX 1000 uint key2_time_cnt; //key debounce counter uchar num; uchar key_flag; void Delay_mS(uint n) { uint j; uchar k; for(j=0;j NOP(); } void key_scan() { if(GP2==0) //button pressed { while(key2_time_cnt!=TIME_MAX) { key2_time_cnt++; } key_flag=1; } else { key2_time_cnt=0; if(key_flag==1) { key_flag=0; num++; if(num>2) num=0; } } } void main() { TRISGPIO=0b00000100; GP0=1; GP1=0; while(1) { key_scan(); switch(num) { case 0: GP0=1; // white light is on GP1=0; break; case 1: GP0=0; GP1=1;break;//Huang Guangliang case 2: GP0=0; GP1=1; Delay_mS(5); GP0=1; GP1=0; Delay_mS(5);break; //Alternate flashing } } }
Previous article:PIC10F202 makes a button to switch two relays
Next article:(Haier) Neusoft MCU HR7P153 SOP-16 digital tube display program
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- RF2051 chip
- [Repost] Analysis of transistor level conversion and driving circuit
- FDC2214_F5529_Good Program
- MSP430G2 LaunchPad, how to play music with buzzer
- Microvision Notebook PCMCIA Color and Black and White Image Capture Card
- Disassemble a WSN node device and see how to select materials?
- Allwinner V853 heterogeneous multi-core AI intelligent vision development board review - V853 YOLO V3 test
- Development board CC3200-LAUNCHXL,
- How to remove the red cross on the schematic diagram
- TMS320F28335 Study Notes——DMA