Based on 51 microcontroller buttons to control the speaker to produce a variety of sounds

Publisher:XinmeiLatest update time:2024-02-26 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Specific implementation functions:


The 51 microcontroller buttons control the speaker to emit a variety of sounds.


Design introduction

5ebc978e-57cc-11ee-939d-92fbcf53809c.png

Introduction to 51 microcontroller

The 51 monolithic chip is a low-power, high-performance CMOS-8-bit microcontroller with 8K programmable Flash memory, making it a highly flexible and ultra-effective solution for many embedded control application systems.

The 51 series microcontrollers have the following standard features:

8k bytes Flash, 512 bytes RAM,

32-bit I/O port line, watchdog timer,

Built-in 4KB EEPROM,

MAX810 reset circuit,

Three 16-bit timer/counters,

A 6-vector 2-level interrupt structure,

Full duplex serial port.

In addition, in the idle mode of the 51 series, the CPU stops working and allows the RAM, timers/counters, serial ports, and interrupts to continue working. In power-down protection mode, the RAM contents are saved, the oscillator is frozen, and the microcontroller stops working until the next interrupt or hardware reset. The chip used in this design is compatible with all the following 51 series microcontrollers (including AT series and STC series).

5edd19d2-57cc-11ee-939d-92fbcf53809c.png

Design ideas

Literature research method: collect and organize relevant research materials, read literature, and prepare for research;

Investigation and research method: Discover relevant existing problems and solutions through investigation, analysis, specific experiments and other methods;

Comparative analysis method: Compare the specific principles of different designs and the performance differences of the same type of sensors, and analyze the research status and development prospects of the system;

Software and hardware design method: realize the hardware through software and hardware design, and finally test whether each function meets the requirements.

Reference template for microcontroller design papers:

Worry-free Graduation | MCU Graduation Thesis Template

design content

Simulation diagram (protues8.7)

This design uses protues8.7 software to implement simulation design, as shown in the figure.

Note: Free sharing, please follow the picture below to draw the simulation yourself! !

5ee49900-57cc-11ee-939d-92fbcf53809c.png

protues8.7 software information and simulation solutions:

proteus8.7 installation and cracking tutorial (installation package included)

Solutions to common problems in protues simulation

Protues8.7 simple tutorial

Program (Keil5)

This design uses KEIL5 software to implement programming.

Note: All codes are shared for free, please create your own project! !


This design is written in C language, and the entire code is as follows:


#include 

#define uchar unsigned char

#define uint unsigned int



sbit BEEP = P3^7;

sbit K1 = P1^4;

sbit K2 = P1^5;

sbit K3 = P1^6;

sbit K4 = P1^7;



void DelayMS(uint x)

{

   uchart;

  while(x--)

  {

     for(t=0;t<120;t++);

  }

}



void Play(uchar t)

{

   uchar i;

  for(i=0;i<100;i++)

  {

     BEEP = ~BEEP;

    DelayMS(t);

  }

  BEEP = 0;

}



void main()

{

   P1 = 0xff;

  while(1)

  {

     if(K1==0) Play(1);

    if(K2==0) Play(2);

    if(K3==0) Play(3);

    if(K4==0) Play(4);

  }

}

The running result is as shown in the figure:

9b5f694bf7de515b2f839513e93b9418_wKgZomULmCCAAjLpAAHCucibPOQ021.png

Reference address:Based on 51 microcontroller buttons to control the speaker to produce a variety of sounds

Previous article:Implementation of container safety monitoring device and system design based on C8051F410 microcontroller
Next article:Application plan of temperature acquisition and monitoring system based on 8051F350 microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号