Update 5 (7th Nov '07)

Update : Managed to get PIC to read 3 characters of data. Data starts from 0-255.

I've programmed the PIC to light up LEDs according to the level of pressure from the input in steps of 50.
e.g 0-50,
51-100
101-150
151-200
201-250.

Below is the full working program.

#include <16F76.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)

#define RED PIN_B5
#define GREEN PIN_A5
#include <string.h>
#include <stdlib.h>

// this character array will be used to take input from the prompt
char input [ 30 ];
// this will hold the current position in the array
int index,result;
// this will signal to the kernal that input is ready to be processed
int1 input_ready;
// different commands
char en1 [ ] = "100";
//char en2 [ ] = "hel";
char zero[]="0";

// serial interupt
#int_rda
void serial_interrupt ( )
{
if(index<29) {
input [ index ] = getc ( ); // get the value in the serial
// recieve reg
putc ( input [ index ] ); // display it on the screen
result=atoi(input);//converts string into an integer value

if(input[index]==0x0d){ // if the input was enter
putc('\n');
input [ index ] = '\0'; // add the null character
input_ready=TRUE; // set the input read variable to true
index=0; // and reset the index
}
else if (input[index]==0x08){ //if input was backspace
if ( index > 1 ) {
putc(' ');
putc(0x08);
index-=2;
}
}

else if(result<=50) {
output_bit(PIN_B0,1);
output_bit(PIN_B1,0);
output_bit(PIN_B2,0);
output_bit(PIN_B3,0);
}
else if(result>50 && result<=100) {
output_bit(PIN_B0,0);
output_bit(PIN_B1,1);
output_bit(PIN_B2,0);
output_bit(PIN_B3,0);
}
else if(result>100 && result<=150) {
output_bit(PIN_B0,0);
output_bit(PIN_B1,0);
output_bit(PIN_B2,1);
output_bit(PIN_B3,0);
}
else if(result>150 && result<=200) {
output_bit(PIN_B0,0);
output_bit(PIN_B1,0);
output_bit(PIN_B2,0);
output_bit(PIN_B3,1);
}
else if(result>200 && result<=250) {
output_bit(PIN_B0,0);
output_bit(PIN_B1,0);
output_bit(PIN_B2,1);
output_bit(PIN_B3,1);
}

index++;
}

else{
putc ( '\n' );
putc ( '\r' );
input [ index ] = '\0';
index = 0;
input_ready = TRUE;
}
}

void main ( ) {
// initialize input variables
index=0;
input_ready=FALSE;
// initialize interrupts
enable_interrupts(int_rda);
enable_interrupts(global);
while(TRUE){
printf("O"); to connect to server
delay_ms(1000);
}
end while

}

In short, I've made a working planar antenna and the PIC can now obtain data from the internet without any problems.
Will now proceed to integrate Matchport with Loyyong's output circuit.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License