Exemplo n.º 1
0
/**@fn char Check_For_Object(OBJECT_LOCATION *location)
 * @brief checks to see if there is an object on the belt, and finds its X position
 * @param [in] *location pointer to an OBJECT_LOCATION struct to store object location data to
 * @returns 1 if object is detected, else 0
 * @note also writes X location data to the OBJECT_LOCATION struct
 */
char Check_For_Object(OBJECT_LOCATION *location)
{
	int rangeBuff = 0;
	int temp;
	char i;

	temp = ReadIR(IR_X);
	//check to see if there was an object detected
	if((temp <= X_MAX)&&(temp >= X_MIN))
	{
		//take the average of 16 measurements to determine X position
		for(i = 0; i<16; i++)rangeBuff+=ReadIR(IR_X);
		rangeBuff = rangeBuff/16;
		location->xLocation = rangeBuff;
		return 1;
	}
	return 0;
}
Exemplo n.º 2
0
/********************************************************************
 * Function:        void ProcessIO(void)
 * Overview:        This function is a place holder for other user
 *                  routines. It is a mixture of both USB and
 *                  non-USB tasks.
 *******************************************************************/
void ProcessIO(void)
{   
    LED1_PORT = 0;
    IRLED_PORT = 0;

    ButtonProc();
    ReadIR();
    SendIR();
}
Exemplo n.º 3
0
/**@fn char Check_In_Range(OBJECT_LOCATION *location)
 * @brief checks to see if the object is in grabber range, and finds its Y position
 * @param [in] *location pointer to an OBJECT_LOCATION struct to store object location data to
 * @returns 1 if object is in range, else 0
 * @note also writes Y location data to the OBJECT_LOCATION struct
 */
char Check_In_Range(OBJECT_LOCATION *location)
{
	int rangeBuff = 0;

	rangeBuff = ReadIR(IR_Y);
	location->yLocation = rangeBuff;
	if((rangeBuff <= (Y_MAX + Y_TOL)&&(rangeBuff >= (Y_MIN - Y_TOL))))
	{
		_delay_ms(100);
		return 1;
	}
	return 0;
}