Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- manuelitoys
- Date:
- 2017-09-06
- Revision:
- 0:6155643a7318
File content as of revision 0:6155643a7318:
#include "mbed.h" #define MAXPOS 255 PwmOut myServoX(PB_3); PwmOut myServoY(PB_6); PwmOut myServoZ(PB_4); int coord2pulse(float coord) { if(0 <= coord <= MAXPOS) return int(coord*1000/150+750);// us return 750; } void draw(){ myServoY.pulsewidth_us(750); } void nodraw(){ myServoY.pulsewidth_us(2000); } void vertex2d(float x, float y){ int pulseX = coord2pulse(x); int pulseY = coord2pulse(y); myServoX.pulsewidth_us(pulseX); myServoY.pulsewidth_us(pulseY); } void home() { vertex2d(0 ,0); } void maxpos() { vertex2d(MAXPOS ,MAXPOS); } int main() { // configuracion de periodo myServoX.period_ms(20); myServoY.period_ms(20); myServoZ.period_ms(20); while(1) { draw(); wait(3); home(); wait(3); maxpos(); wait(3); nodraw(); wait(3); } }