Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include < stdio.h >
#include < reg51.h >
#include < Delay.h >
sbit INTO = P3 ^ 2;
sbit TRG = P3 ^ 3;
sbit Buzzer = P3 ^ 7;
void Beep(unsigned char No, unsigned int Delay);
void tmrInit(void);
void tmrReset(void);
unsigned int L1 = 100, L2 = 20;
unsigned int T0_ISR_count = 0;
unsigned int US = 0;
unsigned int CM = 0;
void T0_ISR(void) interrupt 1 {
T0_ISR_count++;
TF0 = 0;
}
void main(void) {
Beep(3, 20000);
TRG = 0;
tmrInit();
while (1) {
tmrReset();
TRG = 1;
DelayI(1000);
TRG = 0;
while (INT0 == 0)
TR0 = 1;
while (INT0 == 1)
TR0 = 0;
US = (unsigned int)((TH0 << 8) | TL0 | ((unsigned int) T0_ISR_count << 16));
CM = US / 58;
if ((CM <= L1) && (CM >= L2)) {
Beep(1, 50 * CM);
}
if (CM <= L2) {
Buzzer = 0;
} else {
Buzzer = 1;
}
DelayL(2000);
}
void tmrReset(void)
T0_ISR_count = 0;
TH0 = 0;
TL0 = 0;
TR0 = 0;
void tmrInit(void)
TMOD = (TMOD & 0xF0) | 0x09;
void Beep(unsigned char No, unsigned int Delay)
unsigned char tNo;
for (tNo = 1; tNo <= No; tNo++) {
Buzzer = 0;
DelayI(Delay);
Buzzer = 1;
DelayI(Delay);
}
}
#include<stdio.h>
#include<reg51.h>
#include<Delay.h>
sbit INTO=P3^2;
sbit TRG=P3^3;
sbit Buzzer=P3^7;
void Beep(unsigned char No,unsigned int Delay);
void tmrInit(void);
void tmrReset(void);
unsigned int L1=100,L2=20;
unsigned int T0_ISR_count=0;
unsigned int US=0;
unsigned int CM=0;
void T0_ISR (void) interrupt 1
{
T0_ISR_count++;
TF0=0;
}
void main (void)
{
Beep(3,20000);
TRG=0;
tmrInit();
while(1)
{
tmrReset();
TRG=1;
DelayI(1000);
TRG=0;
while(INT0==0)
TR0=1;
while(INT0==1)
TR0=0;
US=(unsigned int)((TH0<<8)|TL0|((unsigned int)T0_ISR_count<<16));
CM=US/58;
if((CM<=L1)&&(CM>=L2))
{
Beep(1,50*CM);
}
if(CM<=L2)
{
Buzzer=0;
}
else
{
Buzzer=1;
}
}
DelayL(2000);
}
void tmrReset(void)
{
T0_ISR_count=0;
TH0=0;
TL0=0;
TR0=0;
}
///////////////////////
void tmrInit(void)
{
TMOD=(TMOD & 0xF0)|0x09;
}
void Beep(unsigned char No,unsigned int Delay)
{
unsigned char tNo;
for(tNo=1;tNo<=No;tNo++)
{
Buzzer=0;
DelayI(Delay);
Buzzer=1;
DelayI(Delay);
}
}
Please tell me where.. and is the rest of the code correct??
void tmrReset(void)
T0_ISR_count = 0;
TH0 = 0;
TL0 = 0;
TR0 = 0;
void tmrInit(void)
TMOD = (TMOD & 0xF0) | 0x09;
void Beep(unsigned char No, unsigned int Delay)
unsigned char tNo;
for (tNo = 1; tNo <= No; tNo++) {
Buzzer = 0;
DelayI(Delay);
Buzzer = 1;
DelayI(Delay);
}
void tmrReset(void) {
T0_ISR_count = 0;
TH0 = 0;
TL0 = 0;
TR0 = 0;
}
void tmrInit(void) {
TMOD = (TMOD & 0xF0) | 0x09;
}
void Beep(unsigned char No, unsigned int Delay) {
unsigned char tNo;
for (tNo = 1; tNo <= No; tNo++) {
Buzzer = 0;
DelayI(Delay);
Buzzer = 1;
DelayI(Delay);
}
}
No idea.... The function will be declared in delay.h.... Take a look and see...Is the DelayI(1000); statement correct or i should give DelayI();
Again... a closing brace.... Before or after the delay statement!!Which one