Paso 14: Código Arduino, parte 2
Abrir la boca:
void motorForward(int Speed) { if(current_mouthPosition < targetL) { analogWrite(motor1Pin_O, Speed); analogWrite(motor1Pin_C, 0); currentSpeed = Speed; //save the current speed } else { motorStop(0); } }
void motorReverse(int Speed) { if(current_mouthPosition < 100) { Speed = Speed/2; } if(current_mouthPosition > targetH) { analogWrite(motor1Pin_O, 0); analogWrite(motor1Pin_C, Speed); currentSpeed = Speed; //save the current speed } else { motorStop(0); } }
void motorStop(int Speed) { analogWrite(motor1Pin_O, 0); //motor controller pin for opening mouth analogWrite(motor1Pin_C, 0); //motor controller pin for closing mouth }