|
|
@ -18,6 +18,13 @@ int umbral[]={1023,1023,1023,1023,1023,1023,1023,1023}; |
|
|
|
int numSensores=8;//total de sensres en la barra
|
|
|
|
int ir =2;//encender y apagar la barra
|
|
|
|
|
|
|
|
#define PWMA 9 |
|
|
|
#define AIN2 8 |
|
|
|
#define AIN1 7 |
|
|
|
#define BIN1 5 |
|
|
|
#define BIN2 4 |
|
|
|
#define PWMB 3 |
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
//----------------------INICIALIZACION------------------------
|
|
|
@ -31,6 +38,20 @@ void setup() { |
|
|
|
pinMode(LED_BUILTIN,OUTPUT); |
|
|
|
//pin para controlar el encendido de la barra
|
|
|
|
pinMode(ir,OUTPUT); |
|
|
|
|
|
|
|
//pines para controlar motores
|
|
|
|
pinMode(PWMA,OUTPUT); |
|
|
|
pinMode(PWMB,OUTPUT); |
|
|
|
pinMode(AIN1,OUTPUT); |
|
|
|
pinMode(AIN2,OUTPUT); |
|
|
|
pinMode(BIN1,OUTPUT); |
|
|
|
pinMode(BIN2,OUTPUT); |
|
|
|
//establecer direccion de los motores
|
|
|
|
digitalWrite(AIN1,HIGH); |
|
|
|
digitalWrite(AIN2,LOW); |
|
|
|
digitalWrite(BIN1,HIGH); |
|
|
|
digitalWrite(BIN2,LOW); |
|
|
|
|
|
|
|
digitalWrite(ir,HIGH);//Encendemos la barra
|
|
|
|
calibracion(); |
|
|
|
} |
|
|
@ -48,9 +69,15 @@ void loop() { |
|
|
|
Serial.print("\t"); |
|
|
|
} |
|
|
|
Serial.println(pos); |
|
|
|
|
|
|
|
acelerar(50,50); |
|
|
|
delay(100); |
|
|
|
} |
|
|
|
|
|
|
|
void acelerar(int motIzq, int motDer){ |
|
|
|
analogWrite(PWMA,motIzq); |
|
|
|
analogWrite(PWMA,motDer); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|