LAB09_Oppgave1
Dependencies: mbed
Fork of LAB09_Oppgave1 by
Diff: main.cpp
- Revision:
- 2:0dcac9edd3dc
- Parent:
- 1:e5f12ffcf32f
- Child:
- 3:8a79c1dcefaa
diff -r e5f12ffcf32f -r 0dcac9edd3dc main.cpp --- a/main.cpp Wed Oct 21 11:10:55 2015 +0000 +++ b/main.cpp Fri Oct 23 15:07:14 2015 +0000 @@ -5,13 +5,26 @@ int main() { //sørg for å at servoMotor pulsen har en // Periode tid på .01 sek + servoMotor.period(0.010); while (true) { - //Roter Servo hodet minus 60 grader - // servoMotor har pusbredde på 1000 us - wait(0.2); - //Roter Servo hodet pluss 60 grader - // servoMotor har pusbredde på 2000 us - wait(0.2); + + for(int i = 1000; i <= 2100; i+= 10) + { + if(i == 2100) + { + for(; i >= 900; i-=10) + { + servoMotor.pulsewidth_us(i); + wait_ms(5); + } + } + servoMotor.pulsewidth_us(i); + wait_ms(5); + } + + + + } }