Skip to content

Instantly share code, notes, and snippets.

@iotguider
Last active March 16, 2018 10:37
Show Gist options
  • Save iotguider/a2ba029c693bcafb9105b422813bb100 to your computer and use it in GitHub Desktop.
Save iotguider/a2ba029c693bcafb9105b422813bb100 to your computer and use it in GitHub Desktop.
Code for H-Bridge Motor Driver in Arduino
int input1 = 11; //Number of Motor Input 1 Pin
int input2 = 9; //Number of Motor Input 2 Pin
void setup() {
pinMode(input1, OUTPUT); //Initialize Input 1 Pin
pinMode(input2, OUTPUT); //Initialize Input 2 Pin
}
void loop() {
analogWrite(input1, 0); //Write Analog value to Input 1
analogWrite(input2, 255); //Write Analog value to Input 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment