Lee Nam Cheol / Mbed OS lab04-i2c-master
Committer:
namcheol
Date:
Tue Apr 21 12:20:31 2020 +0000
Revision:
1:89d23c8072af
Parent:
0:f31836d48420
Child:
2:b7fe18d989bc
lab03-pwm-sg90-servo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dshin 0:f31836d48420 1 #include "mbed.h"
dshin 0:f31836d48420 2
namcheol 1:89d23c8072af 3 PwmOut servo(PTA1); //servo = PTA1
dshin 0:f31836d48420 4
dshin 0:f31836d48420 5 int main()
dshin 0:f31836d48420 6 {
namcheol 1:89d23c8072af 7 float w;
namcheol 1:89d23c8072af 8
namcheol 1:89d23c8072af 9 servo.period(20.0 / 1000.0); //period = 20ms for SG90 servo
namcheol 1:89d23c8072af 10 while (true) { //500 ~ 2500us for degree 0 to 180
namcheol 1:89d23c8072af 11 for(w = 500; w <= 2500; w += 100) {
namcheol 1:89d23c8072af 12 servo.write(w / (20.0 * 1000.0));
namcheol 1:89d23c8072af 13 thread_sleep_for(1000);
namcheol 1:89d23c8072af 14 }
dshin 0:f31836d48420 15 }
dshin 0:f31836d48420 16 }