//CONTROL MOTOR L298
Enviado por m.rojas.m • 24 de Abril de 2019 • Tutorial • 817 Palabras (4 Páginas) • 296 Visitas
//CONTROL MOTOR L298
//MOTOR1
const int enm1=3;
const int in1=4;
const int in2=5;
const int speed1= 250;
const int speedM1= 245;
//MOTOR2
const int enm2=6;
const int in3=7;
const int in4=8;
const int speed2=250;
const int speedM2=247;
//MOTOR3
const int enm3=9;
const int in5=10;
const int in6=11;
const int speed3= 250;
//pulsador
int p=12;
int pulsador=0;
//delay
int T= 1000;
int TM1= 580;
int T1= 530;
int TM2= 510;
int t= 2000;
//tiempos garra
int TT= 50;
int tt= 60;
void setup (){
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(enm1, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enm2, OUTPUT);
pinMode(in5, OUTPUT);
pinMode(in6, OUTPUT);
pinMode(enm3, OUTPUT);
pinMode(p, INPUT);
}
void loop()
{
pulsador= digitalRead(p);
if(pulsador==HIGH){
for(int i=1;i<=1;i++)
{
digitalWrite(in1, LOW);//primer avance
digitalWrite(in2, HIGH);
analogWrite(enm1, speed1);
delay(T);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(t);
digitalWrite(in3, HIGH);//segundo avance
digitalWrite(in4, LOW);
analogWrite(enm2, speed2);
delay(T1);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(t);
digitalWrite(in5, LOW);//tercer avance GARRA
digitalWrite(in6, HIGH);
analogWrite(enm3, speed3);
delay(tt);
digitalWrite(in5, LOW);
digitalWrite(in6, LOW);
delay(t);
delay(T);
digitalWrite(in5, HIGH);//RETOCESO1 GARRA
digitalWrite(in6, LOW);
analogWrite(enm3, speed3);
delay(TT);
digitalWrite(in5, LOW);
digitalWrite(in6, LOW);
delay(t);
digitalWrite(in3, LOW);//RETOCESO2
digitalWrite(in4, HIGH);
analogWrite(enm2, speedM2);
delay(TM2);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(t);
digitalWrite(in1, HIGH);//RETOCESO3
digitalWrite(in2, LOW );
analogWrite(enm1, speedM1);
delay(T);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
...