1. Basic hardware DIY design
Circuit Hardware:
[Peripherals]Buzzer/24 LEDs/4 corner buttons
1) Overall schematic diagram
2) PCB circuit
3) 3D_PCB
TOP layer
2. MCU Programming
1) Breathing light [simple analog PWM]
//Breathing light [PWM modulation]
while(1)
{
for(high=1;high P2=P1=P0=0XFF; delay2(high); P2=P1=P0=0X00; low=cycle-high; delay2(low); } for(low=1;low P2=P1=P0=0XFF;; high=cycle-low; delay2(high); P2=P1=P0=0X00; delay2(low); } } 2) Buzzer music // Define the simple blue and white porcelain music score [timer generates music pulse] // Define the simple blue and white porcelain music score [timer generates music pulse] uchar code music[][2]={{0,4}, {0,4},{24,4},{24,4},{21,4},{19,4},{21,4},{14,8},{19,4},{21,4},{24,4},{21,4},{19,16},{0,4},{24,4},{24,4},{21,4},{19,4},{21,4},{12,8},{19,4},{21,4},{24,4},{19,4},{17,16},{0,4},{17,4},{19,4},{21,4}, {24,4},{26,4},{24,4},{22,4},{24,4},{21,4},{21,4},{19,4},{19,16},{0,4}, {17,4},{19,4},{17,4},{17,4},{19,4},{17,4},{19,4},{19,4},{21,8},{24,4},{21,4},{21,12},{0,4},{24,4},{24,4},{21,4},{19,4},{21,4},{14,8},{19,4},{21,4},{24,4},{21,4},{19,16},{0,4},{24,4},{24,4},{21,4}, {19,4},{21,4},{12,8},{19,4},{21,4},{24,4},{19,4},{17,16},{0,4},{17,4},{19,4},{21,4},{24,4},{26,4},{24,4},{22,4},{24,4},{21,4},{21,4},{19,4},{19,12},{12,4},{21,8},{19,4},{19,8},{17,16}, {0xFF,0xFF}}; //Buzzer music [Timer generates music pulse] while(1) { m=music[i][0];n=music[i][1]; if(m==0x00) {TR0=0;delay1(n);i++;} else if(m==0xFF) {TR0=0;delay1(30);i=0;} else if(m==music[i+1][0]) {TR0=1;delay1(n);TR0=0;pause();i++;} else {TR0=1;delay1(n);i++;} } } 3) Several simple water lights //Buzzer music [Timer generates music pulse] void disp10() //State 10: All LEDs are turned off (3 LEDs with 8 grids are turned off counterclockwise) { for(i=0;i<9;i++) { P0=table5[i]; P2=table4[i]; P1=table4[i]; delay(100); } delay(300); } void disp11() //State 11 The 3 LEDs are lit for 8 consecutive grids and rotate clockwise { for(j=0;j<2;j++) { for(i=0;i<8;i++) { P0=table0[i]; P2=table1[i]; P1=table1[i]; delay(100); } P0=0xff; P2=0xff; P1=0xff; for(i=0;i<8;i++) { P0=table0[i]; P2=table1[i]; P1=table1[i]; delay(100); } P0=0xff; P2=0xff; P1=0xff; } } void disp12() //3 LEDs light up intermittently for 8 grids, and then gradually light up clockwise (until all are lit) { for(i=0;i<8;i++) { P0=table2[i]; P2=table3[i]; P1=table3[i]; delay(100); } delay(1000); } void disp13() //State 13: All LEDs are turned off (3 LEDs with 8 grids of intervals start to turn off clockwise) { for(i=0;i<8;i++) { P0=table4[i]; P2=table5[i]; P1=table5[i]; delay(100); } delay(300); } void disp14() //State 14: LED turns off to full brightness (gradually lights up from P0.0, P1.0, P1.7, and P2.0) { for(i=0;i<8;i++) { P0=table2[i]; P2=table2[i]; if(i<4) { P1=table8[i]; } delay(100); } } void disp15() //State 15: LED turns from fully lit to fully off (gradually turns off from P0.7, P1.3, P1.4, and P2.7) { for(i=0;i<8;i++) { P0=table5[i]; P2=table5[i]; if(i<4) { P1=table11[i]; } delay(100); } } 3. Effect display 1) Top-level diagram of the physical circuit 2) Physical circuit bottom diagram The interior is relatively simple (* ̄︶ ̄) 3) Overall effect diagram Rechargeable design Built-in lithium battery connected to lithium battery charging module [can be charged via mini-USB charging port] Playability Three debug buttons and one reset button are reserved The program can be improved: Press the function key to switch modes directly without pressing reset.
Previous article:Learning experience of addressing mode of single chip microcomputer C51 assembly instruction
Next article:Getting Started with 51 MCU - Lighting up the First LED
- 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
- 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
- Can sensorless drive completely replace sensory drive?
- Motor drive development communication 3: Software component description
- MP3302DJ chip drives 640*480 LCD screen heating problem
- Is the baud rate for communication between microcontrollers set in advance? Or calculated? Also, why does the crystal oscillator have 11.0592...
- DALSA P3-80-08K40 Line Scan Camera Teardown
- CircuitPython 6.0.0 Alpha 1 released
- I have a problem with the wire pulling. Version 21. Please help me.
- [ESP32-Audio-Kit Audio Development Board Review] 1. Unboxing photos and official information, first power-on
- EEWORLD University ---- Robust Control Theory
- 【GD32307E-START】+ TFT screen driver and icon interface drawing