-
-
Save OMikeGray/c4e0196704a4d62db5507ad8297708f4 to your computer and use it in GitHub Desktop.
Motor Driver Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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