Created
November 20, 2012 13:41
-
-
Save robertovalenzuela91/4117995 to your computer and use it in GitHub Desktop.
Movimiento del brazo
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
char val; | |
int ledpingreen = 13; | |
int potPin = 1; | |
int E1 = 10; | |
int M1 = 12; | |
int E2 = 11; | |
int M2 = 13; | |
int potLectura = 0; | |
void setup() | |
{ | |
pinMode(ledpingreen, OUTPUT); | |
pinMode(M1, OUTPUT); | |
pinMode(M2, OUTPUT); | |
pinMode(E1, OUTPUT); | |
pinMode(E2, OUTPUT); | |
Serial.begin(115200); | |
} | |
void loop() { | |
potLectura = analogRead(potPin); | |
Serial.println(potLectura); | |
val = Serial.read(); | |
Serial.println(val); | |
if(val == 'D'){ | |
Serial.println("entre der"); | |
if(potLectura >= 600){ | |
digitalWrite(ledpingreen, HIGH); | |
digitalWrite(M1,HIGH); | |
digitalWrite(M2,HIGH); | |
digitalWrite(E1, HIGH); | |
digitalWrite(E2, HIGH); | |
Serial.println("Derecha"); | |
delay(2000); | |
digitalWrite(M1,LOW); | |
digitalWrite(M2,LOW); | |
digitalWrite(E1, LOW); | |
digitalWrite(E2, LOW); | |
Serial.println("Apagado"); | |
} | |
} | |
if(val == 'I'){ | |
Serial.println("entre izq"); | |
if(potLectura <= 1000){ | |
digitalWrite(ledpingreen, HIGH); | |
digitalWrite(M1,LOW); | |
digitalWrite(M2,LOW); | |
digitalWrite(E1, HIGH); | |
digitalWrite(E2, HIGH); | |
Serial.println("Izquierda"); | |
delay(2000); | |
digitalWrite(M1,LOW); | |
digitalWrite(M2,LOW); | |
digitalWrite(E1, LOW); | |
digitalWrite(E2, LOW); | |
Serial.println("Apagado"); | |
} | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment