https://github.com/lemonpi/motorcontroller
Arduino library for a H-Bridge motor controller
https://github.com/lemonpi/motorcontroller
Last synced: 5 months ago
JSON representation
Arduino library for a H-Bridge motor controller
- Host: GitHub
- URL: https://github.com/lemonpi/motorcontroller
- Owner: LemonPi
- Created: 2017-10-31T20:40:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-12T15:15:55.000Z (over 8 years ago)
- Last Synced: 2025-02-22T18:40:31.473Z (about 1 year ago)
- Language: C++
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Arduino library for a H-Bridge motor controller (driver) of a single motor
Two ways to use this:
1. Drop directory directly inside sketch
or
1. Move directory under Arudino libraries directory
2. In Arduino IDE with sketch open select Sketch > Include Library > WheelEncoder (should be under Contributed Libraries)
## Usage
Connect pins according to data sheet
```c++
#include
#include
// H-Bridge pins
constexpr auto LOGIC_C = 8;
constexpr auto LOGIC_D = 9;
constexpr auto ENABLE_A = 3;
MotorController mc(LOGIC_C, LOGIC_D, ENABLE_A);
void setup() {
mc.setSpeed(50U);
}
void loop() {
// clockwise for 1s
mc.goClockWise();
delay(1000);
// coast stop (give 2 seconds)
mc.floatStop();
delay(2000);
// counterclockwise for 1s
mc.goCounterClockWise();
delay(1000);
// hard stop (give 2 seconds and compare difference with float stop)
mc.fastStop();
delay(2000);
}
```