Update 12 (14th Feb '08)

News :
I've processed the input sensors data from 0->250 to 0->9 so the so the highest pressure case on all input sensors is XXX999999999999XXX. This makes it easier for the PIC on the output side to process the data.
This can be properly reflected on the PIC with LEDs . I have only 7 LEDs but at least any 7 of these LEDs will light up when input sensors 2 to 8 are pressed.
Here are snips of the PIC code.

// serial interupt
#int_rda
void serial_interrupt ( )
{
flag=1;
if(index<12) { //for server=12

input [ index ] = getc ( ); // get the value in the serial
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 ( index > 1 ) {
putc(' ');
putc(0x08);
index-=2;
}
}

index++;
}

else{
flash=result;

input [ index ] = '\0';
index = 0;
input_ready = TRUE;

//clears input and adds to sum
for(c=0;c<=12;c++){
if(input[c]>='2'){
sum=sum+4;
str[c]='1'; //for LEDs to represent input sensors

}end if
}
end for

}//end else

}//end serial interrupt

// To convert string to integer format for output(1XXXXXXX) The X's represent input sensors 2->8
//RESET PIN OF MATCHPORT MUST BE 1
str[0]='1';

for(g=0;g<=6;g++)
{
if(gotit==0){
if(str[g]=='1')
{gotit=1;}}

if( gotit == 1 ){
if(str[g+1]=='0'){
t=t*2;
}
else if(str[g+1] == '1'){
t=t*2+1;
}
}end it gotit=1
}
end for loop
output_b(t);
//reset str[]
str[0] = '1';
for(v=1;v<=7;v++)
{str[v]='0';
}

delay_ms(70);
clear();

//RESET t
t=1;

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