Hi,
i am connecting PIC16f877a to my laptop using a USB-serial converter and then to handphone T630. Meanwhile, I am waiting for my USB-serial cable order to reach my doorstep.
My idea is when sensor is triggered, buzzer sounds and calling a number.
Below is my code :
#include <pic.h>
__CONFIG(0x3F32);
#define sensor RA0
#define sw RA1
#define buzzer RC5
#define led RC4
#define BAUD 9600
#define _XTAL_FREQ 20000000
void uart_transmit(char data);
void uart_string(const char*s);
void uart_transmit(char data){
while (TXIF==0)continue;
TXREG='j';
}
void uart_string(const char*s)
{while(*s)
uart_transmit(*s++);
}
void main (void)
{
ADCON1 = 0x06;
TRISA=0b11111111;
TRISC=0b00000000;
TXSTA=0b00100000;
RCSTA=0b10010000;
SPBRG=265;
SYNC=0;
BRGH=1;
SPEN=1;
TXEN=1;
sensor=0;
sw=0;
buzzer=0;
led=0;
while(1)
{
if ((sensor == 0) && (sw ==0))
{ led=1,buzzer=1;
uart_string("ATD++60136289844:");//call
uart_transmit(0x0D);}//enter
else if ((sensor == 0) && (sw ==1))
{ led=0,buzzer=0;}
else {led =0,buzzer =0;}
}
}
Now because i do not have the USB Serial cable, i cannot test the code. I am not so familiar with the UART_TRANSMIT , please give me some advises on the code, i felt something is wrong there.
P/S: compilation no errors.. >.<