ARDUINO DE IDENTIFICACIÓN
DE SEGUIMIENTO TCRT5000 MÁS SISTEMA DE VEHÍCULO INTELIGENTE DE DOS RUEDAS.
El proyecto de automóvil
inteligente reconoce la línea de seguimiento en blanco y negro, y el módulo del
sensor está alrededor de la rueda universal.
El módulo de identificación TCRT5000
tiene un LED y el disparador estará encendido. El principio básico es la
reflexión infrarroja.
Cuanto más baja sea la
posición de instalación, mejor. Era demasiado lento para comenzar a instalar
demasiado alto.
Const int SRight = 2;
Const int SLeft = 3;
// derecha, anuncio del sensor
de la rueda izquierda
Const int motorIn1 = 10;
Const int motorIn2 = 9;
Const int motorIn3 = 8;
Const int motorIn4 = 7;
Char val;
Int SRR;
Int SLL;
Byte byteSensorStatus = 0;
Configuración del vacío ()
{
pinMode (SLeft, INPUT);
pinMode (SRight, INPUT);
pinMode (motorIn1, SALIDA);
pinMode (motorIn2, SALIDA);
pinMode (motorIn3, SALIDA);
pinMode (motorIn4, SALIDA);
}
Bucle de vacío () {
byteSensorStatus = 0;
SRR = digitalRead (SRight);
Si (SRR == 1)
byteSensorStatus = (byteSensorStatus |
(0x01 << 1));
SLL = digitalRead (SLeft);
Si (SLL == 1)
byteSensorStatus = (byteSensorStatus |
0x01);
// Identificar la fórmula para el
seguimiento.
Interruptor (byteSensorStatus)
{
Caso 0:
Parada del motor ();
Descanso;
// 0, 0 (negro, negro, parada).
Caso 1:
Izquierda ();
Descanso;
// 1, 0 (blanco, negro, izquierda).
Caso 2:
Correcto ();
Descanso;
// 0, 1 (negro, blanco, giro a la derecha).
Caso 3:
Adelante ();
Descanso;
// 1, 1 (blanco, blanco, adelante).
}
}
Parada del motor vacío ()
{
digitalWrite (motorIn1, LOW);
digitalWrite (motorIn2, LOW);
digitalWrite (motorIn3, LOW);
digitalWrite (motorIn4, LOW);
}
Vacío hacia adelante ()
{
digitalWrite (motorIn1, ALTO);
digitalWrite (motorIn2, LOW);
digitalWrite (motorIn3, ALTO);
digitalWrite (motorIn4, LOW);
}
Vacío hacia atrás ()
{
digitalWrite (motorIn1, LOW);
digitalWrite (motorIn2, ALTO);
digitalWrite (motorIn3, LOW);
digitalWrite (motorIn4, ALTO);
}
Nulo derecho ()
{
digitalWrite (motorIn1, LOW);
digitalWrite (motorIn2, LOW);
digitalWrite (motorIn3, ALTO);
digitalWrite (motorIn4, LOW);
}
Vacío a la izquierda ()
{
digitalWrite (motorIn1, ALTO);
digitalWrite (motorIn2, LOW);
digitalWrite (motorIn3, LOW);
digitalWrite (motorIn4, LOW);

No hay comentarios.:
Publicar un comentario