Ejemplo n.º 1
0
void RoverL298::motorCommandPercent(int motorNum, int percent)
{
  if (percent == 0)
  {
    motorCommand(motorNum, COMMAND_BRAKE, 255);
        // Serial.print("motor brake ");
    // Serial.println(motorNum);
  }
  else if (percent < 0)
  {
    motorCommand(motorNum, COMMAND_REVERSE, (percent * 1.55) + 100);
    // Serial.print("motor RV: ");
    // Serial.print(motorNum);
    // Serial.print(" @ ");
    // Serial.println((percent * 1.55) + 100);
    
  }
  else 
  {
    motorCommand(motorNum, COMMAND_FORWARD, (percent * 1.55) + 100);
    // Serial.print("motor FW: ");
    // Serial.print(motorNum);
    // Serial.print(" @ ");
    // Serial.println((percent * 1.55) + 100);
  }
}
Ejemplo n.º 2
0
void comHandler() {

	if (commandBuffer[0] == SOP) {
		switch (commandBuffer[1]) {

		case 'M':
			motorCommand();
			break;

		case 'S':
			//servo command
			Serial.print(commandBuffer);
			break;

		case 'R':
			// request for data
			if (commandBuffer[2] == 'B') {
				char tb[10];
				sprintf(tb, "<B,%d>", analogRead(A0));
				strcpy(returnBuffer, tb);
				returnReady = true;
			} else {
				Serial.print(commandBuffer);
			}
			break;

		default:
			return;
		}
	}
}
void Trex_Rover::accelMotors(int left, int right)
{
	uint8_t cmd[3];
	motorCommand(Accelerate_Motors, left, right, cmd);
	_trex.sendCommand(cmd);
}
void Trex_Rover::setMotors(int left, int right)
{
	uint8_t cmd[3];
	motorCommand(Set_Motors, left, right, cmd);
	_trex.sendCommand(cmd);
}