sfchew7
Junior Member level 2
Can anyone tell me how to solve the while loop problem? I dont want the printF keep looping. if I remove the while(1) then the LED will no longer turn on. Is that anyway I can make this code to work when the LED turns on and will show the message ("available")only once and turn off will show the message ("Not available") once. thanks I am using PIC16F877A and ccs compiler.
#include "16f877a.h"
#fuses HS,PROTECT,NoWDT,put,brownout
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS)
void main()
{
while(1)
{
if(input(pin_a0)==1)
{
output_low(pin_b0);
printf("Not available");
}
else
{
output_high(pin_b0);
printf("Available");
}
if(input(pin_a1)==1)
{
output_low(pin_b1);
printf("Not available");
}
else
{
output_high(pin_b1);
printf("Available");
}
}
}
#include "16f877a.h"
#fuses HS,PROTECT,NoWDT,put,brownout
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS)
void main()
{
while(1)
{
if(input(pin_a0)==1)
{
output_low(pin_b0);
printf("Not available");
}
else
{
output_high(pin_b0);
printf("Available");
}
if(input(pin_a1)==1)
{
output_low(pin_b1);
printf("Not available");
}
else
{
output_high(pin_b1);
printf("Available");
}
}
}