How to control servo I need help

hi,

i am making a game. I work with levels. Every time the player gives the right answer, the level goes up by one. now I added a micro servo SG90, every time the player gives the right answer, it now moves to 180 degrees. however I want to use the micro servo as an scale or parking lot meter. so that every time the player gives the right answer, it will go up around 20 degrees, and not all the way up.

my problem I don’t know how to code it like that. now the servo moves to 20degrees, and with the next question the servo goes back down to 0 degrees and then to 20 degrees. I need a code, that adds the degrees to the last degrees. (so that it will go from 0 20 to 40 to 60 to 80 etc)

Suppose that the number of the current level is held in a variable named currentLevel and the number of degrees to move with each level is named degreesPerLevel and is set to 20 then you could do myServo.write(currentLevel * degreesPerLevel);

Please give us material so that we can help you.
I suggest that before posting read:

thank you for helping again. this worked for me! very grateful thank you.

hi the problem is solved, next time I will provide the material as well, thank you for taking your time to comment!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.