0% found this document useful (0 votes)
4 views3 pages

Assessment

Uploaded by

jingskie588
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Assessment

Uploaded by

jingskie588
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CEDRIC REY IGNACIO BSIT 4-A

1.
a. If the LED is connected to the ground and GPIO25:

from gpiozero import LED


from signal import pause

red = LED(25)

red.blink()

B. If the LED is connected to the ground and Pin number 5 of GPIO


(assuming Pin 5 refers to GPIO3):

from gpiozero import LED


from signal import pause

red = LED(3)

red.blink()

pause()

c. If the LED is connected to Pins number 25 and Pin number 31 of


GPIO.
from gpiozero import LED
from signal import pause

red = LED(25, active_high=False)


red.blink()
pause()

2. (30 points) The code used in LED with variable brightness is


shown below:
a. If the LED is connected to the ground and GPIO25.

python
Copy
from gpiozero import PWMLED
from time import sleep

led = PWMLED(25)

while True:
led.value = 0 # off
sleep(1)
led.value = 0.5 # half brightness
sleep(1)
led.value = 1 # full brightness
sleep(1)
b. If two LEDs were used and connected to the ground and pin
number 16 (for LED 1) and pin number 18 (for LED 2).

python
Copy
from gpiozero import PWMLED
from time import sleep
led1 = PWMLED(16)
led2 = PWMLED(18)

while True:
led1.value = 0 # off
led2.value = 0 # off
sleep(1)
led1.value = 0.5 # half brightness
led2.value = 0.5 # half brightness
sleep(1)
led1.value = 1 # full brightness
led2.value = 1 # full brightness
sleep(1)

You might also like