JPH
Joined: 02 Feb 2005 Posts: 9 Location: Finland
|
Converting array to int |
Posted: Thu Jan 19, 2006 7:42 am |
|
|
Hello
Is there simple easy to convert INPUT information to int. I'm trying to read DIP switch information and convert it to 8-bit int. Any suggestions?
Code: |
int16 READ_DIP(void)
{
int16 dip_value=0;
int16 dip[4]={0,0,0,0};
char i=0, j=0;
dip[i]=input(PIN_D4);
i++;
dip[i]=input(PIN_D5);
i++;
dip[i]=input(PIN_D6);
i++;
dip[i]=input(PIN_D7);
for(j=0; j < 4;j++)
{
//itoa(dip[j],2,k[j]);
//dip_value += dip[j];
}
//value += bit_test (var, bit)
return(dip_value);
}
|
|
|