Skip to content

Instantly share code, notes, and snippets.

@Will-Firgelli
Last active February 26, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Will-Firgelli/c0ef0871dc1946d75257e0c29dccae2a to your computer and use it in GitHub Desktop.
Save Will-Firgelli/c0ef0871dc1946d75257e0c29dccae2a to your computer and use it in GitHub Desktop.
/* 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