Skip to content

Instantly share code, notes, and snippets.

@panchiga
Created April 14, 2015 15:03
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 panchiga/14db2c4a99707a511026 to your computer and use it in GitHub Desktop.
Save panchiga/14db2c4a99707a511026 to your computer and use it in GitHub Desktop.
const int motor1 = 5; // output for motor1 on 5pin(pwm)
const int motor2 = 6; // output for motor2 on 6pin(pwm)
const int button = 2;
int buttonState = 0;
void setup() {
pinMode(motor1, OUTPUT); // declare the motor1 as an OUTPUT
pinMode(motor2, OUTPUT); // declare the motor1 as an OUTPUT
pinMode(button, INPUT);
/*** make motor stop ***/
analogWrite(motor1, 0);
analogWrite(motor2, 0);
Serial.begin(9600);
Serial.println("start");
}
void loop() {
buttonState = digitalRead(button);
Serial.println(buttonState);
if(buttonState == 1){
/*** ccw ***/
analogWrite(motor1, 0);
//analogWrite(motor2, 255 - (a_input /2) );
analogWrite(motor2, 200);
//Serial.print("minus");
//Serial.println(255 - (a_input /2));
} else{
analogWrite(motor1, 0);
analogWrite(motor2, 0);
}
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment