Created
May 9, 2016 01:14
-
-
Save ricardojlrufino/0bade5bfeddf5de266d6d20471393975 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
#include <Servo.h> | |
// NAO MUDAR NADA AQUI.. | |
void setup () | |
{ | |
// NAO MUDAR NADA AQUI... | |
} | |
void loop() | |
{ | |
if (Serial.available() > 0) { | |
char c = Serial.read(); | |
//Se o "c" for igual ao caracter "I" (73 na tabela ASCII) | |
//PEGANDO A PEÇA E VOLTANDO PARA A POSIÇÃO INICIAL. | |
////////////////////////////IDA//////////////////////////////// | |
if (c == 73) { | |
mover(s1, 90, 158, true); | |
mover(s3, 50, 18, false); | |
mover(s2, 90, 139, true); | |
// REPETE.... | |
} | |
///////////////////////////////////////////////////////////////// | |
//COLOCANDO A PEÇA NA POSIÇÃO 'A'. (c = a = 97) | |
///////////////////////////////IDA//////////////////////////////// | |
if (c == 97) { | |
// REPETE mover(X, X, X, true); | |
} | |
} | |
} // void loop | |
void mover(Servo servo, int inicio, int fim, bool incremento) { | |
if (incremento) { | |
for (int pos = inicio; pos <= fim; pos++) { | |
servo.write(pos); | |
delay(15); | |
} | |
} else { | |
for (pos = inicio; pos >= fim; pos--) { | |
servo.write(pos); | |
delay(15); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment