本文整理汇总了C++中Motor::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ Motor::attach方法的具体用法?C++ Motor::attach怎么用?C++ Motor::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motor
的用法示例。
在下文中一共展示了Motor::attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/*
* Updates the fields of current motor and sets the Heading
* of its pins
*/
void MotorController::init()
{
// Attach motors
leftMotor.attach(LEFT_MOTOR_IN_A_PIN, LEFT_MOTOR_IN_B_PIN, LEFT_MOTOR_PWM_PIN);
rightMotor.attach(RIGHT_MOTOR_IN_A_PIN, RIGHT_MOTOR_IN_B_PIN, RIGHT_MOTOR_PWM_PIN);
// Attach encoders
leftEncoder.attach(LEFT_ENCODER_INT_PIN, LEFT_ENCODER_DIGITAL_PIN);
rightEncoder.attach(RIGHT_ENCODER_INT_PIN, RIGHT_ENCODER_DIGITAL_PIN);
// Consider the starting point of the robot
// as its origin
_position.setX(0);
_position.setY(0);
// Suppose robot is heading along Y axis
_heading = 90;
// Initialize the number of commands to 0
_commandsCount = 0;
_processingNewCommand = true;
_leftMotorPosition = 0;
_leftMotorLastPosition = 0;
_rightMotorPosition = 0;
_rightMotorLastPosition = 0;
_leftMotorSpeed = 0;
_rightMotorSpeed = 0;
_leftMotorPWM = 0;
_rightMotorPWM = 0;
// Set vacuum pump pin as output
pinMode(VACUUM_PIN, OUTPUT);
stopVacuum();
}
示例2: setup
void setup() {
Serial.begin(9600);
Serial.println("Serial communication established");
/*
SERVO_FRONT.attach(SERVO_FRONT_PIN);
SERVO_BACK.attach(SERVO_BACK_PIN);
SERVO_GRAB.attach(SERVO_GRAB_PIN);
*/
m1.attach(M1_EN_PIN, M1_INA_PIN, M1_INB_PIN);
m2.attach(M2_EN_PIN, M2_INA_PIN, M2_INB_PIN);
//roomba.start();
//roomba.safeMode();
//roomba.fullMode();
}