Home > other >  Pure new small white consult a great god
Pure new small white consult a great god

Time:10-11

Where is the following code has a problem?
Protus simulation out buzzer is only a man's voice, no tones, the simulation circuit in CSDN on other great spirit of the code is can speak
Just contact with SCM consult!


#include
#include
Sbit LED=P0 ^ 0;
Sbit BUZZER=P2 ^ 2;

Unsigned char timeH, timeL, time;

# define uchar unsigned char
# define uint unsigned int

/*
# define M1 0 xf91e
# define M2 0 xf9de
# define M3 0 xfa8a
# define the M4 0 xfad8
# define the M5 0 xfb68
# define M6 0 xfbe8
# define M7 0 xfc5a
# define H1 0 xfc8f
*/

Code unsigned MUSICh []=
XFC XFC {0, 0, 0 XFB, 0 XFB, 0 xfa, 0 xfa, 0 xf9, 0 xf9};
Code unsigned MUSICl []=
Xe8 x5a x8f {0, 0, 0, 0 x68, 0 xd8, 0 x8a, 0 xde, 0 x1e};
/*
Code unsigned MUSIC []=
{the H1, M7, M6, M5, M4, M3, M2 and M1};
*/


Void Delay (unsigned char t)
{
Do {
XDC TH0=0;
TL0=0 x00;

TR0=1;
while (! TF0);
TR0=0;
TF0=0;
} while (t!=0);
}


Void T0INTSVS () interrupt 1
{
TR0=0;

TH0=timeH;
TL0=timeL;
TR0=1;
BUZZER=! BUZZER.
}

Void PlayMusic ()
{
TH0=timeH;
TL0=timeL;
TR0=1;
BUZZER=1;
Delay(30);
BUZZER=0;
Delay (70);

}


Void main ()
{

Unsigned char I;
TMOD & amp;=0 xf0;
TMOD |=0 x01;
ET1=1;
EA=1;
/*
For (;; )
{
P0=0 x00;
BUZZER=0;

Delay (30);
P0=0 XFF;
BUZZER=1;
Delay (70);
}
*/

While (1)
{


For (;; )
{

P0=0 XFF;

TimeH=MUSICh [0];
TimeL=MUSICl [0];
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [1];
TimeL=MUSICl [1];
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [2];
TimeL=MUSICl [2];
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [3].
TimeL=MUSICl [3].
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [4];
TimeL=MUSICl [4];
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [5];
TimeL=MUSICl [5];
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [6].
TimeL=MUSICl [6].
PlayMusic ();

P0=_crol_ (P0, 1);

TimeH=MUSICh [7];
TimeL=MUSICl [7];
PlayMusic ();

P0=_crol_ (P0, 1);
}
}


}

CodePudding user response:

It is best to use physical proteus simulation and sometimes is a big difference phenomenon, after all, is the simulation of the real thing

CodePudding user response:

You this software logic look a little dizzy, T0, T1 interruption which is what use? They know not

CodePudding user response:

refer to the second floor hufuju_com response:
this software logic you look a little dizzy, T0, T1 interruption which is what use? They know there is no

Ah, I use the t0, t1 may I have a Duan Gaicheng like, online, but I really don't understand,,

CodePudding user response:

reference 1st floor F_ly response:
it is best to use physical phenomenon of proteus simulation and real sometimes difference is very big, after all, is the simulation of

But no physical substance (crying) also didn't go to school at home ~

CodePudding user response:

I also in the graduation design, annoyed

CodePudding user response:

reference 5 floor sun_kissed1998 reply:
I also in the graduation design, dejected

It's just that we're a small assignments think impassability

CodePudding user response:

MCU drive buzzer can play music?

CodePudding user response:

See this code was the first time
  • Related