Software that allows basic remote control of the position of a servo (schematic included in the comments)
Diff: main.cpp
- Revision:
- 3:91070e0c0431
- Parent:
- 2:7aacbdf39425
- Child:
- 4:85a8391945b2
--- a/main.cpp Mon Jan 30 12:29:00 2017 +0000 +++ b/main.cpp Wed Mar 08 23:15:42 2017 +0000 @@ -22,9 +22,13 @@ DigitalOut userLED(LED1); PwmOut towerProSG90(D11); +PwmOut testOutput(D10); InterruptIn userButton(USER_BUTTON); int index; -int pulseDurationInMicroSeconds[]={700, 1550, 2500, 1550}; +int pulseDurationInMicroSeconds[]= +// {10, 1500, 1750, 2000, 1750, 1500, 10, 1500, 1250, 1000, 1250, 1500}; + {1500,1625,1750,1875,2000, 1875,1750,1625,1500,1375,1250,1125,1000,1125,1250,1375}; +//{700, 1550, 2500, 1550} void responseToUserButtonPressed(void) { index++; @@ -33,6 +37,7 @@ index = 0; } towerProSG90.pulsewidth_us(pulseDurationInMicroSeconds[index]); + testOutput.pulsewidth_us(20000 - pulseDurationInMicroSeconds[index]); } int main() @@ -40,6 +45,8 @@ index = 0; towerProSG90.period_ms(PWM_PERIOD_FOR_SG90_IN_MS); towerProSG90.pulsewidth_us(pulseDurationInMicroSeconds[index]); + testOutput.period_ms(PWM_PERIOD_FOR_SG90_IN_MS); + testOutput.pulsewidth_us(20000 - pulseDurationInMicroSeconds[index]); userButton.fall(&responseToUserButtonPressed); while(1)