REPORT PRACTICE 4 NATALIA GALÁN

REPORT PRACTICE 4 NATALIA GALÁN

By Natalia Galán Jiménez 3ºF
  • DESCRIPTION
  • We are going to make a circuit function like a traffic light. And the challenge consists of making the yellow LED flash.
  • DESIGN
    • List of materials
    • Circuits.io Bill Of Materials

      IDS # Footprint
      U1 1 Arduino Uno R3
      D1, D4 2 OSRAM-MINI-TOP-LED
      D2 1 OSRAM-MINI-TOP-LED
      D3, D5 2 OSRAM-MINI-TOP-LED
      R1, R2, R3, R4, R5 5 Resistor 1/4 Watt 220
      R6 1 Resistor 1/4 Watt 10K
      S1 1 TACTILE-PTH
    • Breadboard diagram
    • Schematics
    • Program code
 // Declaramos las constantes asociando el pin a cada LED y pulsador
    const int LEDPinGREENPEDESTRIAN = 3;
      const int LEDPinREDPEDESTRIAN = 4;
        const int buttonPin = 6;
          const int LEDPinGREENVEHICLE = 10;
            const int LEDPinYELLOWVEHICLE = 11;
              const int LEDPinREDVEHICLE= 12;


                  int buttonState = 0; // Declaramos la variable buttonState del pulsador


                      void setup() { // Configuramos los pines digitales de los diodos LED de salida
                        pinMode(LEDPinREDPEDESTRIAN, OUTPUT);
                          pinMode(LEDPinGREENPEDESTRIAN, OUTPUT);
                            pinMode(LEDPinGREENVEHICLE, OUTPUT);
                              pinMode(LEDPinYELLOWVEHICLE, OUTPUT);
                                pinMode(LEDPinREDVEHICLE, OUTPUT);
                                  pinMode(buttonPin, INPUT); // Configuramos el pin del pulsador como entrada digital
                                    }


                                        void loop(){ // Bucle que se ejecuta de forma repetida
                                          buttonState = digitalRead(buttonPin); // Lee el estado del pulsador y lo almacena en buttonState
                                            digitalWrite (LEDPinREDPEDESTRIAN, HIGH); // En el momento inicial está en verde para los coches y en rojo para los peatones
                                              digitalWrite (LEDPinGREENVEHICLE, HIGH);
                                                if (buttonState == HIGH) { // Comprueba si se ha presionado el pulsador; si se ha presionado el pulsador, ponemos buttonState a 1
                                                  delay (2000); // Tras 2 segundos cambia, apaga el verde de los coches y enciende el amarillo de los coches
                                                    digitalWrite (LEDPinGREENVEHICLE, LOW);
                                                      digitalWrite (LEDPinYELLOWVEHICLE, HIGH);
                                                        {
                                                          digitalWrite (LEDPinYELLOWVEHICLE,LOW);
                                                            delay(250);
                                                              digitalWrite (LEDPinYELLOWVEHICLE,HIGH);
                                                                delay(250);
                                                                  digitalWrite (LEDPinYELLOWVEHICLE,LOW);
                                                                    delay(250);
                                                                      digitalWrite (LEDPinYELLOWVEHICLE,HIGH);
                                                                        delay(250); 
                                                                          digitalWrite (LEDPinYELLOWVEHICLE,LOW);
                                                                            delay(250);
                                                                              digitalWrite (LEDPinYELLOWVEHICLE,HIGH);
                                                                                delay(250);
                                                                                  digitalWrite (LEDPinYELLOWVEHICLE,LOW);
                                                                                    delay(250);
                                                                                      } // Despues de 3 segundos, apaga el amarillo, enciende el rojo para los coches y enciende el verde para los peatones
                                                                                        digitalWrite (LEDPinREDPEDESTRIAN, LOW);
                                                                                          digitalWrite (LEDPinYELLOWVEHICLE, LOW);
                                                                                            digitalWrite(LEDPinGREENPEDESTRIAN, HIGH);
                                                                                              digitalWrite (LEDPinREDVEHICLE, HIGH);
                                                                                                delay(5000); // Despues de 5 segundos, los dos semaforos vuelven a cambiar a su estado inicial, coches en verde y peatones en rojo
                                                                                                  digitalWrite (LEDPinGREENPEDESTRIAN, LOW);
                                                                                                    digitalWrite (LEDPinREDVEHICLE, LOW);
                                                                                                      }
                                                                                                        else {
                                                                                                          digitalWrite (LEDPinREDPEDESTRIAN, HIGH); // Si el pulsador no es accionado, se mantiene en verde para los coches
                                                                                                            digitalWrite (LEDPinGREENVEHICLE, HIGH);
                                                                                                              }
                                                                                                                }
                                                                                                                • CONSTRUCTION


                                                                                                                • SELF EVALUATION
                                                                                                                • It was really easy and it was cool to see the circuit work.
                                                                                                                • EMBEDDED SIMULATION

                                                                                                                Comentarios