hisham.i
Joined: 22 Aug 2010 Posts: 43
|
Pic to PC interface |
Posted: Thu Oct 28, 2010 8:33 am |
|
|
am trying to make an interface between pc and pic16f877A, which allows me to switch a led on and off using a push button.
i made the gui in matlab and programed the bushbutton, and then i wrote the microcontroller program, but while i was simulating it nothing happens, i didn't recognize the problem.
this is the code
#include <16f877A.h>
#include <stdio.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock = 4MHZ)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
main()
{ byte a;
setup_uart(9600);
while(1)
{
output_low(PIN_B0);
output_low(PIN_B2);
a=getch();
if(a=="g")
{ output_high(PIN_B0);
delay_ms(500);
}
else
{output_high(PIN_B2);
delay_ms(100);
}
}
}
thanks for help |
|