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.
Fork of 01-01SolucionFuncionXY by
main.cpp
- Committer:
- fabeltranm
- Date:
- 2018-02-20
- Revision:
- 1:370d6730c1cf
- Parent:
- 0:7ba873404776
- Child:
- 2:878cb2697ab1
File content as of revision 1:370d6730c1cf:
#include "mbed.h"
#define MAXPOS 50 // en milimetros
#define SS_TIME 100 // en microsegundos
PwmOut myServoX(PB_3);
PwmOut myServoY(PB_4);
void vertex2d(float x, float y){
int pulseX ;
int pulseY ;
// UBICAR EL CODIGO QUE HACE FALTA
// la funciòn como parametros tiene las coordenadas x y y en milimetros y
// debe calcular las variables pulseX y pulseY para dar paso a la actualizaciòn
// de la posiciòn de los dos servomotores
myServoX.pulsewidth_us(pulseX);
myServoY.pulsewidth_us(pulseY);
wait_ms(SS_TIME);
}
int main() {
// configuracion de periodo
myServoX.period_ms(20);
myServoY.period_ms(20);
int posx=0;
int posy=0;
while(1)
{
wait(2);
vertex2d(posx,posy);
posx+=10;
posy+=10;
if (posx>50) posx=0;
if (posy>50) posy=0;
}
}
