Assignment 12
Output devices
this week i'm going to use the micro servo as an output device
All files, board, datasheets .. etc are available here: week12.rar
i'm going to control a tower pro micro servo "SG90"
after reading the datasheets, the first step was fabricating the PCB, i used neil's board "you can find it in the lecture page
here's the PCB after soldering :


then i started making neil's code to test the board, but unfortunately it didn't work well
the code was supposed to move the servo to make 3 angels (0, 90 and 180) using (1.5, 2 and 1 ms PWM on time)
so i started searching about the problem to understand how to build my code from scratch
i found that i have to determine these parameters : 1- waveform generator WGM. 2- create a period using ICR1 register. 3- prescaler => CS10-12
here's a photo of the result


in the servo datasheet, it supposed to work on 50 HZ

i found that i have a problem in my servos itself!! it doesn't match the datasheet
after many trials i started editing neil's code,, when i put the OCR1A register = 400 the servo moves 0 degree
and when i put the OCR1A register = 2000 the servo moves 180 degree
i really don't understand the reason, but i think it's all about my servo quality
result video
here's a video for the final result, where my attiny controls one servo "all code builds available in the week .rar file"
and here's a video for my attiny controls two servos :