Output 1KHz and 500Hz audio signals to drive speakers

Publisher:vettykattyLatest update time:2014-03-11 Keywords:1KHz  500Hz Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Output 1KHz and 500Hz audio signals to drive speakers

Use P1.0 to output 1KHz and 500Hz audio signals to drive the speaker as an alarm signal. The 1KHz signal is required to sound for 100ms and the 500Hz signal is required to sound for 200ms, alternately. P1.7 is connected to a switch for control. When the switch is closed, the alarm signal sounds, and when the switch is disconnected, the alarm signal stops. Write a program. 2. Circuit Schematic Diagram 
 

Figure 4.6.1 3. Hardware connection on the system board (1. Connect the P1.0 port in the "MCU system" area to the SPK IN port in the "Audio amplifier module" area with a wire; (2. Connect an 8-ohm or 16-ohm speaker to the SPK OUT port in the "Audio amplifier module" area; (3. Connect the P1.7/RD port in the "MCU system" area to the K1 port in the "Four-way toggle switch" area with a wire; 4. Program design content (1. Signal generation method 500Hz signal period is 2ms, signal level is reversed once every 1ms, 1KHz signal period is 1ms, signal level is reversed once every 500us; 5. Program flowchart 
 
 
 
 
 
 
 
  
 

Figure 4.6.2 6. Assembly source program FLAG BIT 00H ORG 00H START: JB P1.7,START JNB FLAG,NEXT MOV R2,#200 DV: CPL P1.0 LCALL DELY500 LCALL DELY500 DJNZ R2,DV CPL FLAG NEXT: MOV R2,#200 DV1: CPL P1.0 LCALL DELY500 DJNZ R2,DV1 CPL FLAG SJMP START DELY500: MOV R7,#250 LOOP: NOP DJNZ R7,LOOP RET END 7. C language source program #include #include  
























bit flag;
unsigned char count;

void dely500(void)
{
unsigned char i;
for(i=250;i>0;i--)
{
_nop_();
}
}

void main(void)
{
while(1)
{
if(P1_7==0)
{
for(count=200;count>0;count--)
{
P1_0=~P1_0;
dely500();
}
for(count=200;count>0;count--)
{
P1_0=~P1_0;
dely500();
dely500();
}
}
}

Keywords:1KHz  500Hz Reference address:Output 1KHz and 500Hz audio signals to drive speakers

Previous article:Signal conditioning circuit for piezoresistive accelerometer
Next article:Delay circuit composed of operational amplifier

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号