Hi there!
I think I see the problem. You are trying to use the .read() function to check if the servo is at a certain degree position. This is not how that function works. Below is code from the Servo source file:
int Servo::read() // return the value as degrees
{
return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
}
According to this code, calling the function requires the argument field(the inside of the parenthesis) to be empty, meaning you cannot put anything there. When the function is called correctly, it will return the degree position that the servo was last sent to. Below is how to use the function properly in your code:
void loop()
{
int position = controlador_CoroaMotora.read();
buttonState = digitalRead(buttonPin); //NOTE this was not in your code that you posted, meaning the
//program will not check for the button state each time
if(buttonState == HIGH && position == 90)
{
controlador_CoroaMotora.write(0);
}
if(buttonState == HIGH && position == 0)
{
controlador_CoroaMotora.write(90);
}
}
Try this code, as well as your variable declarations and setup() portion and let me know how it works.
Good luck!