Single-Chip Microcomputer experiment -- let the speaker make a "Drop, drop" sound

Source: Internet
Author: User

Compiling environment: Keil C51 v3
Simulation Software: Proteus 7.4
Single-Chip Microcomputer type:
Resistance Type: res

Speaker type: Speaker

Audio Amplifier: lm386

Capacitor type: avx1206np010p

 

 

Single-Chip MicrocomputerProgram:

 

<Textarea Cols = "50" rows = "15" name = "code" class = "CPP"> # include <reg52.h> </P> <p> char code table [] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, <br/> 0x6d, 0x7d, 0x07, 0x7f, 0x6f }; </P> <p> bit flag; <br/> unsigned char tcount; <br/> sbit sound_ OK = p1 ^ 0; </P> <p> void main () <br/>{< br/> tmod = 0x02; // Timer/Counter working mode: 16-bit Timer/Counter </P> <p> // load the predefined initial value to the Timer/Counter t0 <br/> th0 = (65535-60000) /256; <br/> tl0 = (65535-60000)/256; </P> <p> tr0 = 1; // set the timer/Counter t0 to the timer Status <br/> et0 = 1; // enable the et0 interrupt timer to allow flag <br/> Ea = 1; // enable CPU interruption flag </P> <p> tcount = 0; </P> <p> while (1) <br/>{}</P> <p >}</P> <p> void t0_interrupt_function (void) interrupt 1 <br/>{< br/> tcount = tcount + 1; </P> <p> If (tcount> = 8) <br/> {<br/> tcount = 0; <br/> flag = ~ Flag; <br/>}</P> <p> If (flag = 0) <br/> {<br/> sound_ OK = ~ Sound_ OK; <br/>}</P> <p >}</textarea>

 

Core Circuit diagram:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.