Created
May 17, 2014 01:28
-
-
Save afcruz/6b8ccb154393deede01e to your computer and use it in GitHub Desktop.
Ejemplo de control de motor DC usando modulo L298
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ejemplo de control de motor DC usando modulo L298 | |
http://electronilab.co/tienda/driver-dual-para-motores-full-bridge-l298n/ | |
Creado 16/05/14 | |
por Andres Cruz | |
ELECTRONILAB.CO | |
*/ | |
int IN3 = 5; // Input3 conectada al pin 5 | |
int IN4 = 4; // Input4 conectada al pin 4 | |
int ENB = 3; // ENB conectada al pin 3 de Arduino | |
void setup() | |
{ | |
pinMode (ENB, OUTPUT); | |
pinMode (IN3, OUTPUT); | |
pinMode (IN4, OUTPUT); | |
} | |
void loop() | |
{ | |
//Preparamos la salida para que el motor gire en un sentido | |
digitalWrite (IN3, HIGH); | |
digitalWrite (IN4, LOW); | |
// Aplicamos PWM al pin ENB, haciendo girar el motor, cada 2 seg aumenta la velocidad | |
analogWrite(ENB,55); | |
delay(2000); | |
analogWrite(ENB,105); | |
delay(2000); | |
analogWrite(ENB,255); | |
delay(2000); | |
// Apagamos el motor y esperamos 5 seg | |
analogWrite(ENB,0); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment