Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
usart_read
char y;
int x,n;
void main()
{trisa=0;porta=0;
usart_init(9600);
for(;;)
{if(usart_data_ready())
{y = USART_Read();
usart_write(y);
PORTa.f0= 1;
x=y-48;
for(n=0;n<x;n++)
{delay_ms(1000);}
porta.f0=0;
}
}
}
this code shows how you can use delay_ms();
to make a variable delay
regards
delay pic16f876a c
because that delay_ms(); is used only with
a constant value but vdelay_ms(); can be used
with variables
but you can use delay_ms();to have a variable delay
but not in a direct way
usart_init() usart_write()
char y;
int x;
void main()
{trisa=0;porta=0;
usart_init(9600);
for(;;)
{if(usart_data_ready())
{y = USART_Read();
usart_write(y);
PORTa.f0= 1;
x=y-48;
x=x*1000;
vdelay_ms(x);
porta.f0=0;
}
}
}
this code will work
but the output is porta.f0
and the time will be...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.