Exemplo n.º 1
0
// Transforms a speed value from [-100, 100] to [0, 180].
unsigned Vehicle::convert_speed(int speed)
{
    speed = constrain(speed, -100, 100);
    unsigned result;
  
    if (speed > 0) {
        attach_servos();
        result = 90 + ((speed * 90) / 100);
    } else if (speed < 0) {
        attach_servos();
        result = 180 - (((100 - speed) * 90) / 100);
    } else if (speed == 0) {
        right.detach();
        left.detach();
    }
  
    return result;
}
Exemplo n.º 2
0
void setup(){

	/*
	 * Change to set your desired pinouts to PWM
	 */
	int attach_these[NUM_SERVOS] = {1, 0, 0, 0, 0, 0, 1};
	attach_servos(attach_these);

	/*
	 * Initially disable charging mode. Will be caught
	 * in runtime loop
	 */
	_disable_charger();

	if(control_mode == SERIAL) init_serial();

}