-
To initialize the DriveCell, create an instance of the
DriveCell
class by specifying the input pins connected to your motor or actuator, then call theInit()
function. Here’s how you can set it up:#include "DriveCell.h" DriveCell myDriveCell(IN1, IN2); // Replace IN1 and IN2 with your specific pins void setup() { myDriveCell.Init(); // Initializes the DriveCell }
Below are the functions provided by the DriveCell
library. Basic functions work on all Arduino board + optimized PWM functions for CodeCell & other ESP32 devices
- Function:
Init()
- Description: Initializes the DriveCell by setting up the GPIO pins and attaching the necessary timers.
myDriveCell.Init(); // Initializes the device
- Function for ESP32:
Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)
- Description for ESP32: Uses PWM and hardware timers to flip the actuator or motor polarity every few milliseconds. The smooth parameter enables smoother transitions.
- Examples:
myDriveCell.Run(true, 50, 500); // Smooth operation at 50% power, flipping every 500 ms
- Function for Other Arduino Devices:
Run(uint16_t flip_speed_ms)
- Description for Other Arduino Devices: Uses simple GPIO toggling with delay for timing.
- Examples:
myDriveCell.Run(500); // Flip every 500 milliseconds
- Function:
Buzz(uint16_t us_buzz)
- Description: This function uses your Actuator to generates a buzzing sound by toggling the state of the actuator at specified microsecond intervals.
- Example:
myDriveCell.Buzz(100); // Buzz at 100 microseconds
- Function for ESP32:
Drive(bool direction, uint8_t power_percent)
- Description for ESP32: Uses PWM to control the speed and direction of the motor or actuator.
- Examples:
myDriveCell.Drive(true, 75); // Drive forward at 75% power
- Function:
Pulse(bool direction, uint8_t ms_duration)
- Description: Creates a short pulse in the specified polarity for the given duration.
- Example for All Devices:
myDriveCell.Pulse(true, 10); // Pulse forward for 10 milliseconds
- Function:
Tone()
- Description: Plays a tone by continuously toggling the motor state with varying frequencies.
- Example for All Devices:
myDriveCell.Tone(); // Play a tone with varying frequencies
-
Function for ESP32:
Toggle(uint8_t power_percent)
-
Description for ESP32: Toggles polarity or motor direction at a specified duty cycle using PWM.
-
Examples:
myDriveCell.Toggle(50); // Toggle direction at 50% power
-
Function for Other Arduino Devices:
Toggle()
-
Description for Other Arduino Devices: Toggles polarity or motor direction using simple GPIO toggling.
-
Examples:
myDriveCell.Toggle(); // Toggle direction or polarity