0% found this document useful (0 votes)
5 views2 pages

6-CodigoFuenteCap8 Evaluacion

This document contains an Arduino sketch that controls a robot's movement and an LED. It defines constants for motor control pins, sets up the pins in the setup function, and implements movement functions for forward, backward, left, right, and stopping. Additionally, it includes a function to blink an LED as an indicator during operation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

6-CodigoFuenteCap8 Evaluacion

This document contains an Arduino sketch that controls a robot's movement and an LED. It defines constants for motor control pins, sets up the pins in the setup function, and implements movement functions for forward, backward, left, right, and stopping. Additionally, it includes a function to blink an LED as an indicator during operation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//Definimos variables

const int AIA = 3;


const int AIB = 11;
const int BIA = 9;
const int BIB = 10;

const int ledTest = 13;

void setup() {

pinMode(AIA, OUTPUT);
pinMode(AIB, OUTPUT);
pinMode(BIA, OUTPUT);
pinMode(BIB, OUTPUT);
pinMode(ledTest, OUTPUT);

analogWrite(AIA, 0);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 0);
digitalWrite(ledTest, LOW);
}

void loop() {

adelante();
delay(1500);
parar();

parpadeo();
atras();
delay(1500);
parar();

parpadeo();
derecha();
delay(1000);
parar();

parpadeo();
izquierda();
delay(1000);
parar();

void adelante()
{
analogWrite(AIA, 255);
analogWrite(AIB, 0);
analogWrite(BIA, 255);
analogWrite(BIB, 0);
}

void atras()
{
analogWrite(AIA, 0);
analogWrite(AIB, 255);
analogWrite(BIA, 0);
analogWrite(BIB, 255);
}
void derecha()
{
analogWrite(AIA, 255);
analogWrite(AIB, 0);
analogWrite(BIA, 0);
analogWrite(BIB, 255);
}

void izquierda()
{
analogWrite(AIA, 0);
analogWrite(AIB, 255);
analogWrite(BIA, 255);
analogWrite(BIB, 0);
}

void parar()
{
analogWrite(AIA, 255);
analogWrite(AIB, 255);
analogWrite(BIA, 255);
analogWrite(BIB, 255);
delay(500);
}

void parpadeo() {
digitalWrite(ledTest, HIGH);
delay(200);
digitalWrite(ledTest, LOW);
delay(200);
}
}

You might also like