///P2 0 Control frequency 10HZ to 50HZ,? News changes
//P2 1 controls account for 10% to 90%, depending on the change.
//Suppose the crystal oscillator is 12MHz?
# include & ltreg52.h & gt
# Definition? uint? Not signed? Internationalorganizations (same as international organizations)
# Definition? Ucal? Not signed? tea
uint? t=0,f= 100,w = 50
sbit? p 10=p 1^0; ? //? output terminal
sbit? kf=p2^0; ? //? Change frequency button
sbit? kw=p2^ 1; ? //? Change width button
Invalid? Initialize ()
{
TMOD = 0x 2 1;
TH0 =(65536- 1000)/256;
TL0 =(65536- 1000)% 256;
ET0 = 1;
TR0 = 1;
EA = 1;
}
Invalid? time0()? Interrupt? 1
{
TH0 =(65536- 1000)/256;
TL0 =(65536- 1000)% 256;
t++; //t is1ms.
if(t & gt; =f)? t = 0;
}
Invalid? Master ()
{
init();
while( 1)
{
What if (KF==0)? //Change the frequency
{ f = f- 10;
if(f & lt; = 10)? f = 100;
while(KF = = 0);
w = f/ 10;
}
if(KW==0)? //Change the proportion
{ w = w+f/ 10;
What if (w & gt=f)? w = f/ 10;
while(KW = = 0);
}
if(t & lt; w)p 10 = 1; ? //single cycle
Or what? p 10 = 0;
}
}
If you can't see the picture clearly, please "view the big picture" first, and then save it to your computer to view the big picture.
****************************
Back-up: According to your "problem-up", you need to add an AD converter. Commonly used parallel port has ADC0809, and serial port has ADC0834. Single-chip microcomputer scans the data output from AD conversion and sends it to the above two variables: frequency f and ratio w, which you can change. The amplitude change is very simple, just use the partial voltage output of potentiometer directly. It takes a certain length to write a complete story, which provides you with ideas. I hope you can use the computer more and get satisfactory results.