Wireless doorbells are also called wireless remote control doorbells or remote control doorbells. Wireless doorbells use super-regenerative wireless modules to achieve wireless remote control. Wireless doorbells do not require wiring and are simple and flexible to install. However, the transmission distance is greatly affected by the transmission distance and the on-site environment. Wired doorbells are just the opposite.
Including, program physical drawings program simulation
Expected results of the course:
1. There are 5 songs to switch between, each press will play a different song.
2. The wireless transmission distance is more than 10m and can pass through walls and doors.
3. Compact design, easy to install and use
4. High stability, no false alarm.
Physical map:
Schematic diagram:
Simulation diagram
Code screenshot
Wireless Music Doorbell Components List
1.79 Multipurpose Board
2.8Ω 0.25w small speaker
3. DC power socket
4. Self-locking switch
5.12m crystal oscillator
6. 10k resistor 8
7. 2.2k resistor
8. 30pf capacitor 2
9. 10uf capacitor
10. 40-pin IC socket
11. Button 2
12. stc89c51
13.315M transmitter module
14. Receiving module
15. 2272-M4 chip
16.2262 Chip
17. 12v battery
18.820k chip resistor
19. 4.7M chip resistor
20.9012
21.9013
22. Several wires
23. Some solder
24.23cm long antenna*2
25. USB power cord (battery box + DC plug)
C language reference source code
//
//51 MCU wireless remote control doorbell program
//
#include #define sound_amount 5 //Number of songs sbit pause=P2^5; //playback pause sbit speaker=P2^7; //passive buzzer // unsigned char timer0h, timer0l, time; //timer0h, timer0l are the initial values of the high and low bits of timer T0, time is the corresponding beat time unsigned char music_num,num; //music_num is the song number, music_num=0 means the state when the machine is just turned on, num is the address to search the song data table signed char fre; //The address of the corresponding frequency data table bit play_enable; //Song playback enable flag, used for playback pause void delay(unsigned char t); //delay subfunction, control the length of pronunciation void delayms(unsigned int t); //Ordinary delay subroutine, can be used to eliminate key jitter void song(void); //play a note void music_play(void); //play songs // //Every three numbers represent a note //The first number is one of the values of the note 1234567 (the note number), representing Do-Re-Mi-Fa... //The second number is one of 0123, representing bass, mid-range, treble, and super-treble (octave) //The third number is the duration, in half beats. The end of the music data table is three 0s. // //"Happy birthday to you" unsigned char code song1[]={ 5,1,1, 5,1,1, 6,1,2, 5,1,2, 1,2,2, 7,1,4, 5,1,1, 5,1,1, 6,1,2, 5,1,2, 2,2,2, 1,2,4, 5,1,1, 5,1,1, 5,2,2, 3,2,2, 1,2,2, 7,1,2, 6,1,2, 4,2,1, 4,2,1, 3,2,2, 1,2,2, 2,2,2, 1,2,4, 0,0,0}; //《There is only one good mother in the world》 unsigned char code song2[]={ 6,2,3, 5,2,1, 3,2,2, 5,2,2, 1,3,2, 6,2,1, //6,2,3 represents 6, middle note, 3 and a half beats; //5,2,1 represents 5, middle note, 1 and a half beats; //3,2,2 represents 3, middle note, 2 and a half beats; //5,2,2 represents 5, middle note, 2 and a half beats; //1,3,2 represents 1, high note, 2 half beats; //… 5,2,1,6,2,4, 3,2,2, 5,2,1, 6,2,1, 5,2,2, 3,2,2, 1,2,1,6,1,1, 5,2,1, 3,2,1, 2,2,4, 2,2,3, 3,2,1, 5,2,2, 5,2,1, 6,2,1, 3,2,2, 2,2,2, 1,2,4, 5,2,3, 3,2,1,2,2,1, 1,2,1, 6,1,1, 1,2,1, 5,1,6, 0,0,0}; //《Who do you think of when you are lonely》 unsigned char code song3[]={ 3,2,2, 3,2,1, 4,2,1, 3,2,2, 2,2,1, 1,2,1, 2,2,2, 5,2,2, 2,2,2, 2,2,3, 1,2,2, 1,2,1, 2,2,1, 1,2,2, 7,1,1, 6,1,1, 7,1,2, 3,2,2, 7,1,2, 7,1,3, 6,1,2, 2,2,1, 3,2,1, 2,2,1, 1,2,1, 6,1,2, 5,1,2, 2,2,1, 3,2,1, 2,2,1, 1,2,1, 6,1,2, 6,1,2, 2,2,1, 3,2,1, 2,2,1, 1,2,1, 6,1,1, 7,1,1, 1,2,6, 0,0,0 }; //"Country road" unsigned char code song4[]={ 3,1,2, 3,1,1, 3,1,1, 6,0,1, 6,0,1, 1,1,2, 6,0,1, 5,0,1, 6,0,4, 6,0,2, 6,0,1 ,6,0,1, 6,0,2, 6,0,1, 1,1,1, 2,1,2, 2,1,1, 3,1,1, 2,1,4, 3,1,1, 3,1,1, 3,1,1, 2,1,1, 4,1,2, 4,1,2, 3,1,2, 2,1,1, 1,1,1, 2,1,4, 7,0,1, 7,0,1, 7,0,1, 6,0,1, 5,0,1, 5,0,1, 6,0,1, 7,0,1, 7,0,1, 6,0,1, 5,0,1, 6,0,4, 6,1,2, 3,1,1, 6,1,1, 7,1,1, 6,1,1, 5,1,1, 5,1,2, 5,1,1, 2,1,1, 5,1,1, 6,1,1, 5,1,1, 4,1,1, 4,1,2, 4,1,1, 3,1,1, 2,1,2, 1,1,1, 2,1,1, 3,1,1, 2,1,1, 1,1,1, 2,1,1, 3,1,4, 6,1,2, 3,1,1, 6,1,1, 7,1,1, 6,1,1, 5,1,1, 5,1,2, 2,1,1, 5,1,1, 6,1,1, 5,1,1, 4,1,1, 0,0,0}; //"farewell" unsigned char code song5[]={ 5,1,2, 3,1,3, 5,1,1, 1,2,3, 6,1,2, 1,2,2, 5,1,4, 5,1,2, 1,1,1, 2,1,1, 3,1,2, 2,1,1, 1,1,1, 2,1,4, 5,1,2, 3,1,1, 5,1,1, 1,2,2, 7,1,1, 6,1,2, 1,2,2, 5,1,4, 5,1,2, 2,1,1, 3,1,1, 4,1,2, 7,0,1, 1,1,4, 6,1,2, 1,2,2, 1,2,4, 7,1,2, 6,1,1, 7,1,1, 1,2,4, 6,1,1, 7,1,1, 1,2,1, 6,1,1, 6,1,1, 5,1,1, 3,1,1, 1,1,1, 2,1,8, 5,1,2, 3,1,1, 5,1,1, 1,2,2, 7,1,1, 6,1,2, 1,2,2, 5,1,4, 5,1,2, 2,1,1, 3,1,1, 4,1,2, 7,0,2, 1,1,4, 0,0,0}; // The high eight bits of the frequency-half-period data table store 28 frequency data of four octaves unsigned char code FREQH[]={ 0xF2, 0xF3, 0xF5, 0xF6, 0xF7, 0xF8, //Bass 1234567 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFC, 0xFC, //1,2,3,4,5,6,7,i 0xFC, 0xFD, 0xFD, 0xFD, 0xFD, 0xFE, // high pitch 234567 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF}; //Super high pitch 1234567 // Frequency-half-cycle data table lower eight bits unsigned char code FREQL[]={ 0x42, 0xC1, 0x17, 0xB6, 0xD0, 0xD1, 0xB6, //Bass 1234567 0x21, 0xE1, 0x8C, 0xD8, 0x68, 0xE9, 0x5B, 0x8F, //1,2,3,4,5,6,7,i 0xEE, 0x44, 0x6B, 0xB4, 0xF4, 0x2D, // high pitch 234567 0x47, 0x77, 0xA2, 0xB6, 0xDA, 0xFA, 0x16}; //Super high pitch 1234567 void main(void) { TMOD=0x11; //T0 T1 are both in working mode 1 ET0=1; //T0 opens interrupt EA=1; //CPU interrupt while(1) { music_play(); //Play a note of the corresponding song according to the current state if(!pause) //Pause key processing { delayms(5); if(!pause) { if(music_num0) //music_num=0 only exists when the device is just powered on and the pause button is not pressed, indicating the state when the device is just powered on. Press the button to start playing from the first song. { music_num=1; //Set the song number to 1 num=0; //play from the beginning play_enable=1; //Allow playback } else { play_enable=~play_enable; speaker=1; } while(!pause) //What to do if you hold down the pause button { if(play_enable0){} //If it is paused, the display time remains unchanged //(play_enable==0 when paused) } }//Pause key processing ends }//while ends } } void delayms(unsigned int t) //MS delay subroutine { unsigned int i,j; for(i=0;i for(j=0;j<123;j++) ; } } void delay(unsigned char t) //delay subfunction, control the length of pronunciation, 0.4S per beat { unsigned char t1; unsigned long t2; for(t1=0;t1 for(t2=0;t2<8000;t2++) //During the delay period, you can enter T0 interrupt to pronounce { ; } } TR0=0; //Turn off T0, stop pronunciation } void timer0(void) interrupt 1 //T0 interrupt program, control the tone of pronunciation { speaker=!speaker; // output square wave, pronunciation TH0=timer0h; //The next interrupt time, this time controls the pitch TL0=timer0l; } void song(void) //play a note { TH0=timer0h; //control tone TL0=timer0l; TR0=1; //Start T0, and T0 will output square wave sound delay(time); //Playing time of each note } void music_play(void) //Play a note of the corresponding song { if((music_num1)&&(play_enable1)) { fre=song1[num]+7song1[num+1]-1; //The i-th is a note, the i+1th is the octave timer0h=FREQH[fre]; //Read the frequency value from the data table, which is actually the timing time length timer0l=FREQL[fre]; time=song1[num+2]; //Read the time length value num+=3; if(fre==-1) //Judge the end of the song and go to the next one after it ends { num=0; //Play the next song from the beginning music_num=2; play_enable=0; } song(); //send a note } if((music_num2)&&(play_enable1)) { fre=song2[num]+7song2[num+1]-1; timer0h=FREQH[fre]; timer0l=FREQL[fre]; time=song2[num+2]; num+=3; if(fre==-1) { num=0; music_num=3; play_enable=0; } song(); } if((music_num3)&&(play_enable1)) { fre=song3[num]+7song3[num+1]-1; timer0h=FREQH[fre]; timer0l=FREQL[fre]; time=song3[num+2]; num+=3; if(fre==-1) { num=0; music_num=4; play_enable=0; } song(); } if((music_num4)&&(play_enable1)) { fre=song4[num]+7song4[num+1]-1; timer0h=FREQH[fre]; timer0l=FREQL[fre]; time=song4[num+2]; num+=3; if(fre==-1) { num=0; music_num=5; play_enable=0; } song(); } if((music_num5)&&(play_enable1)) { fre=song5[num]+7*song5[num+1]-1; timer0h=FREQH[fre]; timer0l=FREQL[fre]; time=song5[num+2]; num+=3; if(fre==-1) { num=0; music_num=1; play_enable=0; } song(); } } //End of program
Previous article:Mobile phone Bluetooth control Guangzhou Tower LED light array wireless control music playback
Next article:Literacy: What is MCU timing and how to understand the timing diagram
- 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
- Keep up with the latest news in 2018: fast charging and wireless charging, Bluetooth and smart home and GaN
- Application of LOTO oscilloscope with VI curve tester in circuit board maintenance
- About PCB board to make a set of playing cards
- [Silicon Labs BG22-EK4108A Bluetooth Development Evaluation] 1. Unboxing + Data Collection + Development Environment Construction + Lighting
- Please help provide the entire PCB board production process and the SMD component mounting process animation. Thank you
- Summary of DSP's real clock system--Explained with TI's DSP TMS320F2812 as an example
- E840-DTU device unresponsive problem
- Is it better to first increase the voltage to 5V and then decrease it to 3.3V when using a 3.7V lithium battery? Or is it better to first decrease it to 3.3V and then increase it to 5V?
- Download the Pomona Connectors catalogue and win a Xiaomi Mosquito Repellent!
- Are smaller components better?