hardware classes
Embed:
(wiki syntax)
Show/hide line numbers
Servo.h
00001 #include "stdint.h" 00002 #include "mbed.h" 00003 00004 class Servo : private PwmOut 00005 { 00006 private: 00007 int period; 00008 int center; 00009 int maximum; 00010 int minimum; 00011 int position; 00012 00013 public: 00014 Servo(PinName); 00015 //constructor sets defaults and starts servo with 0% duty cycle 00016 void setposition (int); 00017 //set normalized servo position (-255 to 255), default = 0 00018 void setperiod (int); 00019 //set the period in us, default = 20000 00020 void setcenter (int); 00021 //set center deflection pulse width in us, default = 1500 00022 void setmaximum (int); 00023 //set maximum deflection pulse width in us, default = 2400 00024 void setminimum (int); 00025 //set minimum deflection pulse width in us, default = 600 00026 Servo& operator =(int); 00027 //shorthand for setposition, ex: "ServoObj = 231;" 00028 operator int(); 00029 //shorthand for position reading, ex: "check = ServoObj;" 00030 /*NOTE: setposition must be called before any changes to 00031 period, center, maximum, or minimum can take effect*/ 00032 };
Generated on Sun Jul 17 2022 00:19:35 by
1.7.2