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