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@1:370d6730c1cf, 2018-02-20 (annotated)
- Committer:
- fabeltranm
- Date:
- Tue Feb 20 00:39:23 2018 +0000
- Revision:
- 1:370d6730c1cf
- Parent:
- 0:7ba873404776
- Child:
- 2:878cb2697ab1
add commentarios
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| fabeltranm | 0:7ba873404776 | 1 | #include "mbed.h" |
| fabeltranm | 0:7ba873404776 | 2 | #define MAXPOS 50 // en milimetros |
| fabeltranm | 0:7ba873404776 | 3 | #define SS_TIME 100 // en microsegundos |
| fabeltranm | 0:7ba873404776 | 4 | |
| fabeltranm | 0:7ba873404776 | 5 | PwmOut myServoX(PB_3); |
| fabeltranm | 0:7ba873404776 | 6 | PwmOut myServoY(PB_4); |
| fabeltranm | 0:7ba873404776 | 7 | |
| fabeltranm | 0:7ba873404776 | 8 | |
| fabeltranm | 0:7ba873404776 | 9 | |
| fabeltranm | 0:7ba873404776 | 10 | void vertex2d(float x, float y){ |
| fabeltranm | 0:7ba873404776 | 11 | |
| fabeltranm | 1:370d6730c1cf | 12 | int pulseX ; |
| fabeltranm | 1:370d6730c1cf | 13 | int pulseY ; |
| fabeltranm | 1:370d6730c1cf | 14 | |
| fabeltranm | 1:370d6730c1cf | 15 | // UBICAR EL CODIGO QUE HACE FALTA |
| fabeltranm | 1:370d6730c1cf | 16 | // la funciòn como parametros tiene las coordenadas x y y en milimetros y |
| fabeltranm | 1:370d6730c1cf | 17 | // debe calcular las variables pulseX y pulseY para dar paso a la actualizaciòn |
| fabeltranm | 1:370d6730c1cf | 18 | // de la posiciòn de los dos servomotores |
| fabeltranm | 1:370d6730c1cf | 19 | |
| fabeltranm | 0:7ba873404776 | 20 | |
| fabeltranm | 0:7ba873404776 | 21 | myServoX.pulsewidth_us(pulseX); |
| fabeltranm | 0:7ba873404776 | 22 | myServoY.pulsewidth_us(pulseY); |
| fabeltranm | 0:7ba873404776 | 23 | wait_ms(SS_TIME); |
| fabeltranm | 0:7ba873404776 | 24 | |
| fabeltranm | 0:7ba873404776 | 25 | } |
| fabeltranm | 0:7ba873404776 | 26 | |
| fabeltranm | 0:7ba873404776 | 27 | |
| fabeltranm | 0:7ba873404776 | 28 | int main() { |
| fabeltranm | 0:7ba873404776 | 29 | // configuracion de periodo |
| fabeltranm | 0:7ba873404776 | 30 | myServoX.period_ms(20); |
| fabeltranm | 0:7ba873404776 | 31 | myServoY.period_ms(20); |
| fabeltranm | 0:7ba873404776 | 32 | int posx=0; |
| fabeltranm | 0:7ba873404776 | 33 | int posy=0; |
| fabeltranm | 0:7ba873404776 | 34 | while(1) |
| fabeltranm | 0:7ba873404776 | 35 | { |
| fabeltranm | 0:7ba873404776 | 36 | wait(2); |
| fabeltranm | 0:7ba873404776 | 37 | vertex2d(posx,posy); |
| fabeltranm | 0:7ba873404776 | 38 | posx+=10; |
| fabeltranm | 0:7ba873404776 | 39 | posy+=10; |
| fabeltranm | 0:7ba873404776 | 40 | if (posx>50) posx=0; |
| fabeltranm | 0:7ba873404776 | 41 | if (posy>50) posy=0; |
| fabeltranm | 0:7ba873404776 | 42 | } |
| fabeltranm | 0:7ba873404776 | 43 | |
| fabeltranm | 0:7ba873404776 | 44 | } |
| fabeltranm | 0:7ba873404776 | 45 |
