Exemple #1
0
/** Control motor from -255 to +255.
	@param motor
	@param duty 
	@param direction */
void motor_set_one(byte motor, byte duty, byte direction)
{
	if (motor == MOTOR_LEFT && direction == MOTOR_FWD)
	{
		LEFT_DUTY = duty;
		
		// BE CAREFUL!!
		// Set low before high otherwise you'll make
		// a short circuit inside the driver.
		pio_output_low(MOTOR_PIN_L_RVSE);
		pio_output_high(MOTOR_PIN_L_FWD);
	}
	else if (motor == MOTOR_LEFT && direction == MOTOR_RVSE)
	{
		LEFT_DUTY = duty;
		
		// BE CAREFUL!!
		// Set low before high otherwise you'll make
		// a short circuit inside the driver.
		pio_output_low(MOTOR_PIN_L_FWD);
		pio_output_high(MOTOR_PIN_L_RVSE);
	}
	else if (motor == MOTOR_RIGHT && direction == MOTOR_FWD)
	{
		RIGHT_DUTY = duty;
		
		// BE CAREFUL!!
		// Set low before high otherwise you'll make
		// a short circuit inside the driver.
		pio_output_low(MOTOR_PIN_R_RVSE);
		pio_output_high(MOTOR_PIN_R_FWD);
	}
	else if (motor == MOTOR_RIGHT && direction == MOTOR_RVSE)
	{
		RIGHT_DUTY = duty;
		
		// BE CAREFUL!!
		// Set low before high otherwise you'll make
		// a short circuit inside the driver.
		pio_output_low(MOTOR_PIN_R_FWD);
		pio_output_high(MOTOR_PIN_R_RVSE);
	}
}
Exemple #2
0
void process_command( char * string )
{
	if ( strcmp( "on", string ) == 0 )
	{
		pio_output_high(PIO_LED_Y);
	}
	else if (strcmp("off", string) == 0 )
	{
		pio_output_low(PIO_LED_Y);
	}
}
Exemple #3
0
uint8_t adc_measure(uint8_t adc_channel)
{
    uint8_t count;

    count = 0;

    /* Select desired channel.  */
    ACMUX = adc_channel - 1;

    pio_output_high (ADC_CHARGE_PIO);

    while (! (ACSR & BIT(ACO)))
        count++;

    pio_output_low (ADC_CHARGE_PIO);    

    return count;
}