Stap 14: Arduino code, deel 2
Open de mond:
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 }