Compare commits
No commits in common. "e6dc7314151b34ca3d78db8519e81d037b87cc1d" and "129e386bf9d462ca9d4652dd25fcad6ad8ba5212" have entirely different histories.
e6dc731415
...
129e386bf9
@ -2,15 +2,14 @@
|
|||||||
class Base_Robot
|
class Base_Robot
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Motor_DC Motor_1;
|
Motor_DC Motor_1;
|
||||||
Motor_DC Motor_2;
|
Motor_DC Motor_2;
|
||||||
Base_Robot(int IN1,int IN2,int ENA, int IN3, int IN4,int ENB):
|
Base_Robot(int Pin_Motor_1A,int Pin_Motor_1B,int PWM_1, int Pin_Motor_1C, int Pin_Motor_1D,int PWM_2): Motor_1(Pin_Motor_1A,Pin_Motor_1B,PWM_1), Motor_2(Pin_Motor_1C,Pin_Motor_1D,PWM_2){}
|
||||||
Motor_1(IN1,IN2,ENA), Motor_2(IN3,IN4,ENB){}
|
void Inicializar_Robot();
|
||||||
void Inicializar_Robot();
|
void Adelante(int Velocidad_1,int Velocidad_2);
|
||||||
void Adelante(int Velocidad_1,int Velocidad_2);
|
void Atras(int Velocidad_1,int Velocidad_2);
|
||||||
void Atras(int Velocidad_1,int Velocidad_2);
|
void Stop();
|
||||||
void Stop();
|
|
||||||
};
|
};
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h> //Permite utilizar los comandos de Arduino
|
||||||
#include "Motor_DC.h"
|
#include "Motor_DC.h"
|
||||||
|
|
||||||
void Motor_DC::Inicializar_Motor()
|
void Motor_DC::Inicializar_Motor()
|
||||||
{
|
{
|
||||||
pinMode(IN1, OUTPUT);
|
pinMode(A, OUTPUT);
|
||||||
pinMode(IN2, OUTPUT);
|
pinMode(B, OUTPUT);
|
||||||
pinMode(ENA, OUTPUT);
|
pinMode(Pwm, OUTPUT);
|
||||||
}
|
}
|
||||||
void Motor_DC::Atras(int Velocidad)
|
void Motor_DC::Atras(int Velocidad)
|
||||||
{
|
{
|
||||||
analogWrite(ENA,Velocidad );
|
analogWrite(Pwm,Velocidad );
|
||||||
digitalWrite(IN1, HIGH);
|
digitalWrite(A, HIGH);
|
||||||
digitalWrite(IN2, LOW);
|
digitalWrite(B, LOW);
|
||||||
}
|
}
|
||||||
void Motor_DC::Adelante(int Velocidad)
|
void Motor_DC::Adelante(int Velocidad)
|
||||||
{
|
{
|
||||||
analogWrite(ENA,Velocidad );
|
analogWrite(Pwm,Velocidad );
|
||||||
digitalWrite(IN1, LOW);
|
digitalWrite(A, LOW);
|
||||||
digitalWrite(IN2, HIGH);
|
digitalWrite(B, HIGH);
|
||||||
}
|
}
|
||||||
void Motor_DC::Stop()
|
void Motor_DC::Stop()
|
||||||
{
|
{
|
||||||
analogWrite(ENA, 0);
|
analogWrite(0, Pwm);
|
||||||
digitalWrite(IN1, LOW);
|
digitalWrite(A, LOW);
|
||||||
digitalWrite(IN2, LOW);
|
digitalWrite(B, LOW);
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
class Motor_DC
|
class Motor_DC
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int IN1;
|
int A;
|
||||||
int IN2;
|
int B;
|
||||||
int ENA;
|
int Pwm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Motor_DC(int in1,int in2,int ena): IN1(in1), IN2(in2),ENA(ena){}//Constructor
|
Motor_DC(int a,int b,int pwm): A(a), B(b),Pwm(pwm){}//Constructor
|
||||||
void Inicializar_Motor();
|
void Inicializar_Motor();
|
||||||
void Adelante(int Velocidad);
|
void Adelante(int Velocidad);
|
||||||
void Atras(int Velocidad);
|
void Atras(int Velocidad);
|
||||||
void Stop();
|
void Stop();
|
||||||
};
|
};
|
||||||
|
@ -2,37 +2,31 @@
|
|||||||
#include "Sensor_TCRT5000.h"
|
#include "Sensor_TCRT5000.h"
|
||||||
class Robot_Seguidor
|
class Robot_Seguidor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Base_Robot Robot;
|
Base_Robot Robot;
|
||||||
Sensor Sensor_1;
|
Sensor Sensor_1;
|
||||||
Sensor Sensor_2;
|
Sensor Sensor_2;
|
||||||
Sensor Sensor_3;
|
Sensor Sensor_3;
|
||||||
Sensor Sensor_4;
|
Sensor Sensor_4;
|
||||||
Sensor Sensor_5;
|
Sensor Sensor_5;
|
||||||
int sensor[5];
|
int sensor[5];
|
||||||
float Error=0, P=0, I=0, D=0, PID=0;
|
float Error=0, P=0, I=0, D=0, PID=0;
|
||||||
float Error_Anterior=0, Anteriror_I=0;
|
float Error_Anterior=0, Anteriror_I=0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Robot_Seguidor(int Pin_Motor_1A,
|
Robot_Seguidor(int Pin_Motor_1A,
|
||||||
int IN1,
|
int Pin_Motor_1B,
|
||||||
int IN2,
|
int PWM_1,
|
||||||
int ENA,
|
int Pin_Motor_1C,
|
||||||
int IN3,
|
int Pin_Motor_1D,
|
||||||
int IN4,
|
int PWM_2,
|
||||||
int ENB,
|
int PinS1,
|
||||||
int PinS1,
|
int PinS2,
|
||||||
int PinS2,
|
int PinS3,
|
||||||
int PinS3,
|
int PinS4,
|
||||||
int PinS4,
|
int PinS5)
|
||||||
int PinS5)
|
:Robot(Pin_Motor_1A, Pin_Motor_1B, PWM_1, Pin_Motor_1C, Pin_Motor_1D, PWM_2),Sensor_1(PinS1),Sensor_2(PinS2),Sensor_3(PinS3),Sensor_4(PinS4),Sensor_5(PinS5){}
|
||||||
:Robot(IN1, IN2, ENA, IN3, IN4, ENB),
|
void Inicializar();
|
||||||
Sensor_1(PinS1),
|
void Lectura_de_sensores();
|
||||||
Sensor_2(PinS2),
|
void Modo_Seguidor(int kP,int KI,int KD,int Velocidad);
|
||||||
Sensor_3(PinS3),
|
};
|
||||||
Sensor_4(PinS4),
|
|
||||||
Sensor_5(PinS5){}
|
|
||||||
void Inicializar();
|
|
||||||
void Lectura_de_sensores();
|
|
||||||
void Modo_Seguidor(int kP,int KI,int KD,int Velocidad);
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user