Hoooooooooo!!!!!!!!!!!!!!!!!!!!!!!!!!!

Dependencies:   mbed

main.cpp

Committer:
momoka0419
Date:
2020-03-17
Revision:
0:2ef155ddb58d

File content as of revision 0:2ef155ddb58d:

#include "mbed.h"

PwmOut servo90(p23);        //サーボSG90
PwmOut servo92(p24);        //サーボSR92

int main() {
    servo92.period_ms(20);
    servo90.period_ms(20);
    wait(1);
    float ang = 1000;
    float kaku = 1300;
    while(1) {
        
        for(ang = 1000; ang <= 1900; ang += 1){
            servo92.pulsewidth_us(ang);
            wait(0.001); // 1 ms
        }
            
        for(kaku = 1300; kaku <= 1600; kaku += 1){
            servo90.pulsewidth_us(kaku);
            wait(0.001); // 1 ms
        }
            
        for(ang = 1900; ang >= 1000; ang -= 1){
            servo92.pulsewidth_us(ang);
            wait(0.001); // 1 ms
        }   
            
        for(kaku = 1600; kaku >= 1300; kaku -= 1){
            servo90.pulsewidth_us(kaku);
            wait(0.001); // 1 ms
        }   
    }
}