//Infrared decoding, the experimental board tested normal, the 8-bit digital tube displays the remote control code (user code, user inverse code, the 3-digit digital tube on the right displays the PWM value),
//Two 74hc573 drives the 8-bit common cathode digital tube
//CH- key short press to turn on and off the light, + key long press to dim, the digital tube displays the key value; the decoding program for long press dimming is currently difficult to find on the Internet, I pondered for a long time before I adjusted the program//The compressed package contains the complete program code and the waveform of the burst code tested by the logic analyzer
The microcontroller source program is as follows:
#include "INCMY_SET.H"
#include "INCIR_NEC.H" //Call NEC decoding header file
#define DIGI_PORT P0 // Macro definition of digital tube port. If the port changes, just modify this sentence
#define DIGI_NUM 8 // Macro definition of the number of digital tubes
unsigned char digiBuf[DIGI_NUM]; //Digital tube buffer
sfr SE = 0x80; //Digital tube segment selection P0: 0x80 P1: 0x90
sbit wela = P2^7; //bit selection
sbit dula = P2^6; //segment selection
sbit led = P1^2;
uint8 PWM_Val=200; //Duty cycle variable
uint8 flag; //Switch light flag
uint8 flag1; //dimming direction flag
uint8 count;
uint8 flag2; //
uint8 num,pwm;
// 0 1 2 3 4 5 6 7 8 9 A B C D E F not displayed -
uint8 code d[]={ 0x3F,0x06,0x5B,0x4F,0x66, 0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00,0x40}; //Digital tube segment code Common cathode without decimal point segment code
void KZ0(); //Short press processing
//void KZ1(); //Long press processing
/***************** Main function************************/
void main(void)
{
IR_Init(); //Initialize infrared decoding
while(1)
{
//Remote control detection
if(IR_BT==2)
{
KZ0(); //Short press processing
IR_BT =0; // Clear valid flag
//Update the display
digiBuf[0] = NEC[0]/16; //User code
digiBuf[1] = NEC[0]%16;
digiBuf[2] = NEC[1]/16; //User inverse code
digiBuf[3] = NEC[1]%16;
// digiBuf[4] = NEC[2]/16; //data code
// digiBuf[5] = NEC[2]%16;
// digiBuf[6] = NEC[3]/16; //Data inverse
// digiBuf[7] = NEC[3]%16;
}
digiBuf[4] = 16; //not displayed
digiBuf[5] = PWM_Val/100; //Display pwm value
digiBuf[6] = PWM_Val%100/10;
digiBuf[7] = PWM_Val%10;
if(IR_BT==3 && KeyUpDownFlag==0 ) //Long press to dim, release to stop dimming
{
switch(NEC[2])
{ //Long press to receive the burst code, 97.11ms high level, 10.15ms low level
case 0x15: if(IR==1) //if(IR==0)
{
KeyUpDownFlag = 1; //If the key is lifted, the release flag is set to 1
}
if(flag1==1 && flag==0) // Light on + long press to increase brightness
{
if(PWM_Val<200)
{
PWM_Val++; // if(IR==1) use this sentence
// PWM_Val += 5; //if(IR==0) use this sentence to add 5 so that the light brightness changes significantly
if(PWM_Val==200)
flag1=0;
}
}
if(flag1==0 && flag==0) //light on status + long press to reduce brightness
{
if(PWM_Val>0)
{
//PWM_Val -= 5;
PWM_Val--;
if(PWM_Val==0)
flag1=1;
}
} break;
case 0x07:break;
default:break;
}
}
///////////////////////////////////////////
if(flag==0) //Turn on the light
{
for(pwm=200;pwm>0;pwm--)
{
if(PWM_Val led=1; } else { led=0; } } } else { led=1; //Turn off the light } } }
Previous article:Temperature alarm based on 51 single chip microcomputer
Next article:51 single chip temperature + pwm controls the fan speed, and the temperature is displayed on LCD1602
Recommended ReadingLatest update time:2024-11-23 12:37
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- 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
- Production of FM Wireless Headphones
- EEWORLD University ---- Robotics
- EEWORLD University Hall - Wildfire uCOS-III Kernel Implementation and Application Development Practical Guide
- High-density packaging progress
- The Raspberry Pi you want is here. Apply now!
- Selection of capacitors for power supply (JKRL)
- Texas Instruments CC1310 Synchronous Transmit and Receive
- Application of Σ-Δ analog-to-digital conversion circuit AD1555/AD1556
- MTS Displacement Sensors
- C++Test unit testing based on CCS