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.
main.cpp
- Committer:
- fabeltranm
- Date:
- 2019-02-22
- Revision:
- 0:a9181441db9b
- Child:
- 1:b473a0ad2b83
File content as of revision 0:a9181441db9b:
#include "mbed.h"
/*****************************************************************************
generar un programa que controle por el puerto serial el grado de 4 servo motores
por medio de la comunicacion serial donde el comando sea
| | | |
| init_commd | N_motor | N_grados |
| 0xff | 0x01- 0x04 | 0x00 - 0xb4 |
para enviar los comandos usar el programa Coolterm
*****************************************************************************/
Serial command(USBTX, USBRX);
PwmOut myservo1(PB_4);
/*INGRESE L A CONFIGURACION DE LOS MOTORES*/
// definicion de las variables globales
uint8_t nm; // almacena el número de motor
uint8_t ng; // almacena los grados que se mueve el motor
void setup_uart();
void setup_motor();
void mover_servo();
int main() {
myservo1.period_ms(20);
int cw=1;
int dpulse=1000;
myservo1.pulsewidth_us(dpulse);
while(1) {
myservo1.pulsewidth_us(dpulse);
wait(0.5);
if (cw){
dpulse+=100;
if (dpulse==2500)
cw=0;
}else{
dpulse-=100;
if (dpulse==100)
cw=1;
}
}
}