lunes, 24 de abril de 2017

4º día profundiza. Inicio programación Arduino

En este día se inició la programación del vehículo autónomo con el IDE de Arduino, para ello se les explicó la interfaz del IDE, así como conceptos como elegir el tipo de placa controladora (Arduino UNO) y elegir el puerto USB adecuado para garantizar la correcta conexión de la placa al ordenador.

Se les introdujo en la estructura del programa que deben realizar, donde primero se declaran las variables, luego se pone el SETUP donde se inicializa todo el programa, y luego viene el LOOP donde se pone el programa que se va a ejecutar de forma repetida.

El mismo programa del semaforo se realizó con esta IDE y algunos alumnos incluyeron un zumbador y un pulsador que hacía que cambiara su funcionamiento durante un tiempo predefinido.

PROGRAMA SEMAFORO CON PULSADOR

int pulsador=7;
int r=4;
int n=3;
int v=2;
int value=0;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(r, OUTPUT);
  pinMode(n, OUTPUT);
  pinMode(v, OUTPUT);
  pinMode(pulsador,INPUT);
  }

// the loop function runs over and over again forever
void loop() {
value=digitalRead(pulsador);

if (value== HIGH) {
  digitalWrite(r, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  delay(1000);                       // wait for a second
digitalWrite(n, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  delay(1000);                       // wait for a second
  digitalWrite(v, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(v, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(r, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(n, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
    }
    else {
      digitalWrite(v, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(r, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(n, LOW);    // turn the LED off by making the voltage LOW
 
    }
}


En la segunda parte empezaron a desarrollar como proyecto en parejas un videojuego con Scratch, con la idea de exponerlo al final.

No hay comentarios:

Publicar un comentario