i'm working on a school project "automatic railway system" my project suppose to close the gate when the train coming to the station with a buzzer on with 90 sec count down display on 7-seg. and a led flashing. after the train leaving the station, the gate opens and the buzzer off and the led off . i tried to use a dc motor to open and close the gate but it didn't give me the accurate angle that i need to i try to use a servo motor . so i need it to open the gate at position zero and close it at position 90 . all the code i found on the internet they using PWM and timers which i didn't take it in my course , so can anyone help me to do this with simple code ,please ?
i'm using Atmega32 running at 16000000 HZ
Its depend on your analog servo (which is controlled by PWM) frequency specification. After you learn about the servo specification, you can set your PWM using build-in features on cvavr compiler, or you can do some research about PWM registers.
Here is some example of PWM setup