Hola amigos, estube intentando comandar un led por rf pero he fracasado... aqui les envìo los codigos de los programas rx y tx:
TX: envía "A" y "B" alternados cada 1 segundo
RX: si el dato recibido es "A" enciende el led, si es "B" apaga el led...
Pero no funciona :S aqui el código de ambos
TX:
#include <16F628A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=4000000)
#use rs232(baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,FORCE_SW)
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_4MHZ);
set_tris_a (00000000);
set_tris_B (00000000);
//output_a (00000000);
//output_b (00000000);
// TODO: USER CODE!!
while (1){
delay_ms(1000);
printf("A"); //
output_low(pin_B2);
delay_ms(1000);
printf("B"); //
output_low(pin_B2);
}
}
RX:
#include <16F628A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=4000000)
#use rs232(baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,FORCE_SW)
char x=0;
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator(OSC_4MHZ);
set_tris_a (00000000);
set_tris_B (00000010);
//output_a (00000000);
//output_b (00000000);
// TODO: USER CODE!!
while (1){
if (kbhit()) {
x=getc();
if (x=="A") {
output_high (pin_A2);
}
if (x=="B") {
output_low (pin_A2);
}
}
}
}
A ver si alguien me puede ayudar... saludos!!!