Last active
February 26, 2020 23:01
-
-
Save Will-Firgelli/c0ef0871dc1946d75257e0c29dccae2a to your computer and use it in GitHub Desktop.
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 | |
*/ | |
int RPWM = 10; //connect Arduino pin 10 to IBT-2 pin RPWM | |
int LPWM = 11; //connect Arduino pin 11 to IBT-2 pin LPWM | |
int Speed; | |
void setup() { | |
pinMode(RPWM, OUTPUT); | |
pinMode(LPWM, OUTPUT); | |
} | |
void loop() { | |
Speed = 255; //choose any speed in the range [0,255] | |
analogWrite(RPWM, 0); | |
analogWrite(LPWM, Speed); | |
delay(1000); //extend at given speed for one second | |
analogWrite(RPWM, 0); | |
analogWrite(LPWM, 0); | |
delay(500); //stop for half a second | |
analogWrite(RPWM, Speed); | |
analogWrite(LPWM, 0); | |
delay(1000); //retract at maximum speed for one second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment