Blinking

First we did a blink to start working with raspberry and learn, basically the LED will turn on and off when we change the instruction and also we did the turn after some time. To do that we imported the GPIOZERO library and from it the time, and also define the LED.

After that We followed the nexts structures to turn on and off the led:


    #Structure 1
    
      led.on()
      #when we wanted to turn off the led we changed on-->off
      
    #Structure 2
    #t is the time you want the LED to be on or off  
    
      while True:
        led.on()
        time.sleep(t)
        led.off()
        time.sleep(t)
    

Traffic lights

We first connect three LEDS, red, yellow and green, in that order in the protoboard to the raspberry. After that we started doing the code, first we import the libraries GPIZERO and from that the time in order to work with de LED. Then we define the three leds according to the pin they were connected to. After doing that we write a while True and we follow the next structure:


    #t is the time you want the LED to be on or off
    while True:
      ledRed.on()
      time.sleep(t)
      ledRed.off()
      time.sleep(t) 
      ...
    

and the same with the others, when you finish doing that you will have an automatic traffic light, like the one in the street

Joystick

After do the traffic lights project we tried to change the LED on with a joystick, let me explain, I mean if you turn the joystick to the left side the LED in the left will turn on, if you turn the joystick to the right side the LED in the right will turn on and if you press the joystick down the LED in the middle will turn on.

In order to do that first we try to do it with the machine library but that library I don't know the reason didn't work. So after searching a lot we weren't able to find a solution, we asked the teacher to any suggestion and he told us to do it such a LED because we thought it was a digital joystick (0 and 1), and I say tought because after try and try we realised that it was an analogic joystick so we couldn't do it like a LED. Finally we can't finish this project