Codigo de arduino de carro evasor de obstaculos
Enviado por macsor2202 • 28 de Noviembre de 2018 • Tutorial • 679 Palabras (3 Páginas) • 359 Visitas
int MIA=5;
int MIB=6;
int MDA=9;
int MDB=10;
int vel= 255;
int estado= 'c';
int pecho = 2;
int ptrig = 3;
int duracion, distancia;
void setup() {
Serial.begin(9600);
pinMode(MIA, OUTPUT);
pinMode(MIB, OUTPUT);
pinMode(MDA, OUTPUT);
pinMode(MDB, OUTPUT);
pinMode(pecho, INPUT);
pinMode(ptrig, OUTPUT);
}
void loop()
{
digitalWrite(ptrig, HIGH);
delay(0.01);
digitalWrite(ptrig, LOW);
if (distancia <= 15 && distancia >=2) {
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, 0);
delay(200);
analogWrite(MDB, vel);
analogWrite(MIB, vel);
delay(500);
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, vel);
delay(600);
}
else{
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, vel);
analogWrite(MIA, vel);
}
}
int MIA=5;
int MIB=6;
int MDA=9;
int MDB=10;
int vel= 255;
int estado= 'c';
int pecho = 2;
int ptrig = 3;
int duracion, distancia;
void setup() {
Serial.begin(9600);
pinMode(MIA, OUTPUT);
pinMode(MIB, OUTPUT);
pinMode(MDA, OUTPUT);
pinMode(MDB, OUTPUT);
pinMode(pecho, INPUT);
pinMode(ptrig, OUTPUT);
}
void loop()
{
digitalWrite(ptrig, HIGH);
delay(0.01);
digitalWrite(ptrig, LOW);
if (distancia <= 15 && distancia >=2) {
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, 0);
delay(200);
analogWrite(MDB, vel);
analogWrite(MIB, vel);
delay(500);
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, vel);
delay(600);
}
else{
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, vel);
analogWrite(MIA, vel);
}
}
int MIA=5;
int MIB=6;
int MDA=9;
int MDB=10;
int vel= 255;
int estado= 'c';
int pecho = 2;
int ptrig = 3;
int duracion, distancia;
void setup() {
Serial.begin(9600);
pinMode(MIA, OUTPUT);
pinMode(MIB, OUTPUT);
pinMode(MDA, OUTPUT);
pinMode(MDB, OUTPUT);
pinMode(pecho, INPUT);
pinMode(ptrig, OUTPUT);
}
void loop()
{
digitalWrite(ptrig, HIGH);
delay(0.01);
digitalWrite(ptrig, LOW);
if (distancia <= 15 && distancia >=2) {
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, 0);
delay(200);
analogWrite(MDB, vel);
analogWrite(MIB, vel);
delay(500);
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, 0);
analogWrite(MIA, vel);
delay(600);
}
else{
analogWrite(MDB, 0);
analogWrite(MIB, 0);
analogWrite(MDA, vel);
analogWrite(MIA, vel);
}
}
int
...