A simple class which can be used to control a motor through a HBridge (such as the L293).
HBridgeMotor.cpp
- Committer:
- harryeakins
- Date:
- 2011-09-20
- Revision:
- 0:a3bcb7eab9d9
File content as of revision 0:a3bcb7eab9d9:
#include "HBridgeMotor.h" HBridgeMotor::HBridgeMotor(PinName fin, PinName rin):fwd(fin), rev(rin) { power = 0.0; } void HBridgeMotor::set(float power) { if(power >= 0.0) { rev = 0.0; fwd = power; } else { rev = -power; fwd = 0.0; } } float HBridgeMotor::read() { return power; }