Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Car.h
- Committer:
- edmugu
- Date:
- 2019-03-26
- Revision:
- 0:7676da98b5c1
- Child:
- 8:14e91fdf70e8
File content as of revision 0:7676da98b5c1:
#ifndef MBED_MOTOR_H #define MBED_MOTOR_H #include "mbed.h" #include <Motor.h> // DC motor driver struct Car_vector { float speed; float turnCW; }; class Car { public: Car( PinName pwm1, PinName fwd1, PinName rev1, PinName pwm2, PinName fwd2, PinName rev2 ); //Sets the speed as a percentage (i.e. 1 = 100% and 0.5 = 50%) void speed(float speed); float speed(void); //Sets the speed difference between the motors // Example 1: if original speed is 50% // turnCW(0.5) => rightMotor @ 25% and leftMotor @ 75% // turnCW(0.1) => rightMotor @ 45% and leftMotor @ 55% // // Example 2: if original speed is 100% // turnCW(0.5) => rightMotor @ 75% and leftMotor @ 100% // turnCW(0.1) => rightMotor @ 95% and leftMotor @ 100% void turnCW(float turn); protected: void _set_motors(void); float _clamp_speed(float sp); void _mlspeed(float sp); void _mrspeed(float sp); float _car_speed; float _car_turn; PwmOut _ml_pwm; PwmOut _mr_pwm; DigitalOut _ml_fwd; DigitalOut _mr_fwd; DigitalOut _ml_rev; DigitalOut _mr_rev; }; #endif