Example #1
0
//RECEIVER CODE
unsigned char rx_byte (void)
{
	unsigned char j;
	int volt_zero;
	
	while(GetADC(0)<=min);
	wait_bit_time();
	wait_bit_time();

	//Skip the start bit
	val=0;
	//wait_one_and_half_bit_time();
	for(j=0; j<8; j++)
	{
		volt_zero = GetADC(0);
		val|=(volt_zero>min)?(0x01<<j):0x00;
		wait_bit_time();
		
	}
	//printf("Last Command = %u \n",val);
	return val;
}
Example #2
0
int rx_byte (float min)
{
    int j, val;
    int v;
    //skip the start bit
    val = 0;
    Get_ADC(1);
    wait_one_and_half_bit_time();
    for (j=0; j<8; j++)
    {
    v = Get_ADC(1);
    val|=(v>min)?(0x01<<j):0x00; //if voltage is greater than "min" then the returned val gets a bit at the right position
    wait_bit_time();
    }
    //wait for stop bits
    wait_one_and_half_bit_time();
    return val;
}
Example #3
0
unsigned char rx_byte ( float min )
{
	unsigned char j;
	unsigned char val = 0;
	float v;
	int c;

	wait_one_and_half_bit_time();
	
	for(j=0; j<8; j++) {
		v = voltage(0);
		if (j == 0) {
			volt_right = v;
			volt_left = voltage(1);
		}
		c = (v>min);
		P2_0 = c;
		val |= (c)?(0x01<<j):0x00;
		wait_bit_time();
	}
	return val;
}