Library to drive the Zumo shield from pololu.

Dependents:   Nucleo_Zumo_BLE_IDB04A1

https://www.pololu.com/category/169/zumo-robot-for-arduino

Committer:
bcostm
Date:
Mon Oct 12 11:32:33 2015 +0000
Revision:
0:c69b20870374
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:c69b20870374 1 #include "mbed.h"
bcostm 0:c69b20870374 2
bcostm 0:c69b20870374 3 /** Zumo Shield Control Class
bcostm 0:c69b20870374 4 */
bcostm 0:c69b20870374 5 class ZumoShield {
bcostm 0:c69b20870374 6 public:
bcostm 0:c69b20870374 7
bcostm 0:c69b20870374 8 /** Create a Zumo shield object
bcostm 0:c69b20870374 9 *
bcostm 0:c69b20870374 10 * @param m1pwm Motor1 pwm pin
bcostm 0:c69b20870374 11 * @param m1dir Motor1 direction pin
bcostm 0:c69b20870374 12 * @param m2pwm Motor2 pwm pin
bcostm 0:c69b20870374 13 * @param m2dir Motor2 direction pin
bcostm 0:c69b20870374 14 */
bcostm 0:c69b20870374 15 ZumoShield(PinName m1_pwm_pin, PinName m1_dir_pin,
bcostm 0:c69b20870374 16 PinName m2_pwm_pin, PinName m2_dir_pin);
bcostm 0:c69b20870374 17 //PinName a0_pin, PinName a1_pin, PinName a2_pin, PinName a3_pin, PinName a4_pin, PinName a5_pin);
bcostm 0:c69b20870374 18
bcostm 0:c69b20870374 19 /** Switch on the left motor at the given speed.
bcostm 0:c69b20870374 20 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 21 */
bcostm 0:c69b20870374 22 void left_motor(float speed);
bcostm 0:c69b20870374 23
bcostm 0:c69b20870374 24 /** Switch on the right motor at the given speed.
bcostm 0:c69b20870374 25 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 26 */
bcostm 0:c69b20870374 27 void right_motor(float speed);
bcostm 0:c69b20870374 28
bcostm 0:c69b20870374 29 /** Switch on both motors, forwards at the given speed.
bcostm 0:c69b20870374 30 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 31 */
bcostm 0:c69b20870374 32 void forward(float speed);
bcostm 0:c69b20870374 33
bcostm 0:c69b20870374 34 /** Switch on both motors, backwards at the given speed.
bcostm 0:c69b20870374 35 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 36 */
bcostm 0:c69b20870374 37 void backward(float speed);
bcostm 0:c69b20870374 38
bcostm 0:c69b20870374 39 /** Switch on both motors at the given speed, in opposite directions so as to turn left.
bcostm 0:c69b20870374 40 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors.
bcostm 0:c69b20870374 41 */
bcostm 0:c69b20870374 42 void left(float speed);
bcostm 0:c69b20870374 43
bcostm 0:c69b20870374 44 /** Switch on both motors at the given speed, in opposite directions so as to turn right.
bcostm 0:c69b20870374 45 * @param speed The speed, from 0.0 to 1.0 at which to spin the motors.
bcostm 0:c69b20870374 46 */
bcostm 0:c69b20870374 47 void right(float speed);
bcostm 0:c69b20870374 48
bcostm 0:c69b20870374 49 /** Turns left.
bcostm 0:c69b20870374 50 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 51 */
bcostm 0:c69b20870374 52 void turn_left(float speed);
bcostm 0:c69b20870374 53
bcostm 0:c69b20870374 54 /** Turns right.
bcostm 0:c69b20870374 55 * @param speed The speed, from 0.0 to 1.0 at which to spin the motor.
bcostm 0:c69b20870374 56 */
bcostm 0:c69b20870374 57 void turn_right(float speed);
bcostm 0:c69b20870374 58
bcostm 0:c69b20870374 59 /** Stop a chosen motor.
bcostm 0:c69b20870374 60 * @param motor Number, either 1 or 2 choosing the motor.
bcostm 0:c69b20870374 61 */
bcostm 0:c69b20870374 62 void stop(int motor);
bcostm 0:c69b20870374 63
bcostm 0:c69b20870374 64 /** Stop left motor.
bcostm 0:c69b20870374 65 */
bcostm 0:c69b20870374 66 void stopLeft();
bcostm 0:c69b20870374 67
bcostm 0:c69b20870374 68 /** Stop right motor.
bcostm 0:c69b20870374 69 */
bcostm 0:c69b20870374 70 void stopRight();
bcostm 0:c69b20870374 71
bcostm 0:c69b20870374 72 /** Stop both motors at the same time. Different to disable.
bcostm 0:c69b20870374 73 */
bcostm 0:c69b20870374 74 void stopAll();
bcostm 0:c69b20870374 75
bcostm 0:c69b20870374 76 /** Gives an indication of the data given by the reflectivity sensors.
bcostm 0:c69b20870374 77 */
bcostm 0:c69b20870374 78 //float position();
bcostm 0:c69b20870374 79
bcostm 0:c69b20870374 80 private:
bcostm 0:c69b20870374 81 PwmOut m1pwm;
bcostm 0:c69b20870374 82 PwmOut m2pwm;
bcostm 0:c69b20870374 83 DigitalOut m1dir;
bcostm 0:c69b20870374 84 DigitalOut m2dir;
bcostm 0:c69b20870374 85 /*
bcostm 0:c69b20870374 86 AnalogIn a0sens;
bcostm 0:c69b20870374 87 AnalogIn a1sens;
bcostm 0:c69b20870374 88 AnalogIn a2sens;
bcostm 0:c69b20870374 89 AnalogIn a3sens;
bcostm 0:c69b20870374 90 AnalogIn a4sens;
bcostm 0:c69b20870374 91 AnalogIn a5sens;
bcostm 0:c69b20870374 92 */
bcostm 0:c69b20870374 93 };