yotaro morizumi / Mbed 2 deprecated zoomy_customLibrary

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Servomotor.hpp Source File

Servomotor.hpp

00001 #pragma once
00002 #include<mbed.h>
00003 #include<PwmOut.h>
00004 #include<portSet.hpp>
00005 
00006 /*パルスの単位はusでよろ*/
00007 /*
00008        | range degree | pulse cycle | min pulse | max pulse |
00009 DS3218 |180(270もある) |    20000    |   500     |    2500   |
00010 SG90   |      180     |    20000    |   1000    |    2000   |
00011 */
00012 class servo
00013 {
00014 public:
00015     servo(PinName signal,unsigned int range_degree,unsigned int pulse_cycle,unsigned int min_pulse,unsigned int max_pulse);
00016     void Setangle(unsigned int tar_angle);
00017     void Addangle(int tar_angle);
00018     float pulsese;
00019 private:    
00020     PinName signal_;
00021     unsigned int range_degree_;
00022     unsigned int pulse_cycle_;
00023     unsigned int min_pulse_;
00024     unsigned int max_pulse_;
00025     unsigned int now_angle_;
00026     double pdp;/*pulse per degree*/
00027 };