Skip to content

Instantly share code, notes, and snippets.

@OMikeGray
Created May 29, 2020 22:58
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OMikeGray/c4e0196704a4d62db5507ad8297708f4 to your computer and use it in GitHub Desktop.
Save OMikeGray/c4e0196704a4d62db5507ad8297708f4 to your computer and use it in GitHub Desktop.
Motor Driver Example
/* Firgelli Automations
* Limited or no support: we do not have the resources for Arduino code support
*
* Program demos how a motor driver controls direction & speed of a linear actuator
*/
byte Speed = 0; // Intialize Varaible for the speed of the motor (0-255);
int RPWM = 10; //connect Arduino pin 10 to IBT-2 pin RPWM
int LPWM = 11; //connect Arduino pin 11 to IBT-2 pin LPWM
void setup() {
pinMode(10, OUTPUT); // Configure pin 10 as an Output
pinMode(11, OUTPUT); // Configure pin 11 as an Output
}
void loop() {
// Extend Actuator at Full Speed
Speed = 255;
analogWrite(RPWM, 0);
analogWrite(LPWM, Speed);
delay(2000); // 2 Seconds
// Stop Actuator
analogWrite(RPWM, 0);
analogWrite(LPWM, 0);
delay(2000); // 2 Seconds
// Retract Actuator at Half Speed
Speed = 127;
analogWrite(RPWM, Speed);
analogWrite(LPWM, 0);
delay(2000); // 2 Seconds
// Stop Actuator
analogWrite(RPWM, 0);
analogWrite(LPWM, 0);
delay(2000); // 2 Seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment