Controlador da Panificador
Dependencies: BLE_API mbed nRF51822
Fork of BLENano_SimpleControls by
Servo.cpp
00001 /* 00002 00003 Copyright (c) 2012-2014 RedBearLab 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00006 and associated documentation files (the "Software"), to deal in the Software without restriction, 00007 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 00009 subject to the following conditions: 00010 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 00011 00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00013 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00014 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 00015 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00016 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 00018 */ 00019 00020 #include "Servo.h" 00021 00022 Servo::Servo(PinName pin) : _servo(pin) 00023 { 00024 _servo.period_ms(20); 00025 } 00026 00027 Servo::~Servo(void) 00028 { 00029 00030 } 00031 00032 void Servo::write(unsigned char degree) 00033 { 00034 convert(degree); 00035 _servo.pulsewidth_us(pulse); 00036 } 00037 00038 void Servo::convert(unsigned char degree) 00039 { 00040 // 0~180 degree correspond to 500~2500 00041 pulse = degree * 11 + 500; 00042 }
Generated on Wed Jul 13 2022 17:11:43 by 1.7.2