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@2:878cb2697ab1, 2018-03-07 (annotated)
- Committer:
- fabeltranm
- Date:
- Wed Mar 07 00:03:12 2018 +0000
- Revision:
- 2:878cb2697ab1
- Parent:
- 1:370d6730c1cf
- Child:
- 3:fe8e265eaf6e
add nodraw
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 | 2:878cb2697ab1 | 9 | void draw() |
| fabeltranm | 2:878cb2697ab1 | 10 | { |
| fabeltranm | 2:878cb2697ab1 | 11 | |
| fabeltranm | 2:878cb2697ab1 | 12 | // ubicar el codigo respectivo para mover el eje z y dibujar |
| fabeltranm | 2:878cb2697ab1 | 13 | |
| fabeltranm | 2:878cb2697ab1 | 14 | } |
| fabeltranm | 2:878cb2697ab1 | 15 | void nodraw() |
| fabeltranm | 2:878cb2697ab1 | 16 | { |
| fabeltranm | 2:878cb2697ab1 | 17 | |
| fabeltranm | 2:878cb2697ab1 | 18 | // ubicar el codigo respectivo para mover el eje z y no dibujar |
| fabeltranm | 2:878cb2697ab1 | 19 | |
| fabeltranm | 2:878cb2697ab1 | 20 | } |
| fabeltranm | 0:7ba873404776 | 21 | |
| fabeltranm | 0:7ba873404776 | 22 | void vertex2d(float x, float y){ |
| fabeltranm | 0:7ba873404776 | 23 | |
| fabeltranm | 1:370d6730c1cf | 24 | int pulseX ; |
| fabeltranm | 1:370d6730c1cf | 25 | int pulseY ; |
| fabeltranm | 1:370d6730c1cf | 26 | |
| fabeltranm | 1:370d6730c1cf | 27 | // UBICAR EL CODIGO QUE HACE FALTA |
| fabeltranm | 1:370d6730c1cf | 28 | // la funciòn como parametros tiene las coordenadas x y y en milimetros y |
| fabeltranm | 1:370d6730c1cf | 29 | // debe calcular las variables pulseX y pulseY para dar paso a la actualizaciòn |
| fabeltranm | 1:370d6730c1cf | 30 | // de la posiciòn de los dos servomotores |
| fabeltranm | 1:370d6730c1cf | 31 | |
| fabeltranm | 0:7ba873404776 | 32 | |
| fabeltranm | 0:7ba873404776 | 33 | myServoX.pulsewidth_us(pulseX); |
| fabeltranm | 0:7ba873404776 | 34 | myServoY.pulsewidth_us(pulseY); |
| fabeltranm | 0:7ba873404776 | 35 | wait_ms(SS_TIME); |
| fabeltranm | 0:7ba873404776 | 36 | |
| fabeltranm | 0:7ba873404776 | 37 | } |
| fabeltranm | 0:7ba873404776 | 38 | |
| fabeltranm | 0:7ba873404776 | 39 | |
| fabeltranm | 0:7ba873404776 | 40 | int main() { |
| fabeltranm | 0:7ba873404776 | 41 | // configuracion de periodo |
| fabeltranm | 0:7ba873404776 | 42 | myServoX.period_ms(20); |
| fabeltranm | 0:7ba873404776 | 43 | myServoY.period_ms(20); |
| fabeltranm | 0:7ba873404776 | 44 | int posx=0; |
| fabeltranm | 0:7ba873404776 | 45 | int posy=0; |
| fabeltranm | 2:878cb2697ab1 | 46 | draw(); |
| fabeltranm | 0:7ba873404776 | 47 | while(1) |
| fabeltranm | 0:7ba873404776 | 48 | { |
| fabeltranm | 0:7ba873404776 | 49 | wait(2); |
| fabeltranm | 0:7ba873404776 | 50 | vertex2d(posx,posy); |
| fabeltranm | 0:7ba873404776 | 51 | posx+=10; |
| fabeltranm | 2:878cb2697ab1 | 52 | if (posx>50){ |
| fabeltranm | 2:878cb2697ab1 | 53 | posx=0; |
| fabeltranm | 2:878cb2697ab1 | 54 | nodraw(); |
| fabeltranm | 2:878cb2697ab1 | 55 | } |
| fabeltranm | 2:878cb2697ab1 | 56 | posy=posy; |
| fabeltranm | 0:7ba873404776 | 57 | } |
| fabeltranm | 0:7ba873404776 | 58 | |
| fabeltranm | 0:7ba873404776 | 59 | } |
| fabeltranm | 0:7ba873404776 | 60 |
