Created
April 14, 2015 15:03
-
-
Save panchiga/14db2c4a99707a511026 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
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