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.
Dependents: maple_motores maple_heading_pid maple_chotobot_rf_motores motores ... more
motoresDC.h
- Committer:
- tabris2015
- Date:
- 2016-06-10
- Revision:
- 1:5715aefb07ca
- Parent:
- 0:b1e9ffb92a0a
- Child:
- 2:b5d41b0442a7
File content as of revision 1:5715aefb07ca:
/** motoresDC class
* libreria para controlar un driver dual de motores DC
* funciona con drivers como el L293D o el L298N
* se necesitan 6 pines del microcontrolador
* uno para la velocidad (PWM) y 2 para el sentido (digital)
* esta librería esta basada en la libreria RedBot de Sparkfun
*/
#ifndef MBED_MOTORESDC_H
#define MBED_MOTORESDC_H
#include "mbed.h"
class MotoresDC
{
public:
/**inicia la clase con los pines del driver**/
MotoresDC(PinName MI_vel, PinName MI_s1, PinName MI_s2,
PinName MD_vel, PinName MD_s1, PinName MD_s2);
// metodos publicos //
/* funcion para conducir ambos motores en la misma direccion */
void conducir(float velocidad);
void conducir(float velocidad, int duracion);
/* funcion para conducir motores en sentido contrario */
void pivotar(float velocidad);
void pivotar(float velocidad, int duracion);
/* funciones para conducir motores independientemente */
void motorIzq(float velocidad);
void motorDer(float velocidad);
/* funciones para conducir motores independientemente con duracion */
void motorIzq(float velocidad, int duracion);
void motorDer(float velocidad, int duracion);
/* funciones para detener los motores */
void detener(void);
void frenar(void);
void detenerIzq(void);
void detenerDer(void);
void frenarIzq(void);
void frenarDer(void);
/* --------------- */
// metodos y atributos privados //
private:
/* velocidad izquierda */
PwmOut _MI_vel;
/* sentido de giro */
DigitalOut _MI_s1; // motor izq
DigitalOut _MI_s2;
/* velocidad derecha */
PwmOut _MD_vel;
/* sentido de giro */
DigitalOut _MD_s1;
DigitalOut _MD_s2;
/* funciones */
void _izqAdelante(float velocidad);
void _izqAtras(float velocidad);
void _derAdelante(float velocidad);
void _derAtras(float velocidad);
};
#endif