[RaspberryPI]レーザ&FDD

10327 ワード

レーザー


図に示すようにピンを接続します.SGPIOピンの提供
동작 코드
from gpiozero import LED
from time import sleep

lazer = LED(12)

while True:
    lazer.on()
    sleep(1)
    lazer.off()
    sleep(1)

FND

FND:Flexible Numerical Display7-Segment.dpを含めて合計8個のLEDと考えられる.타입 종류1.Common Ande:0(-)로 켠다. 2. Common Cathode : 1(+)`で開きます.

アクションコード


まず、私が使うFDDはAnode方式です.FND Test
from gpiozero import LED
from time import sleep

a = LED(2)
b = LED(3)
c = LED(4)
d = LED(14)
e = LED(15)
f = LED(18)
g = LED(23)
dp = LED(24)
    
seg = [a,b,c,d,e,f,g,dp]

for i in seg:
    i.off()  # 캐소드 방식이면 on으로 켜준다.
0~9 출력
from gpiozero import LED
from time import sleep

a = LED(2)
b = LED(3)
c = LED(4)
d = LED(14)
e = LED(15)
f = LED(18)
g = LED(23)
dp = LED(24)
    
num = [
    [a,b,c,e,f,d], #0
    [b,c], #1
    [a,b,g,e,d],#2
    [a,b,g,c,d],#3
    [f,g,b,c],#4
    [a,f,g,c,d],#5
    [a,f,g,e,d,c],#6
    [f,a,b,c],#7
    [a,b,c,d,e,f,g],#8
    [a,b,f,g,c,d],#9
    ]

while True:
    for i in num[8]:
        i.on()
    for i in range(10):
        for j in num[i]:
            j.off()
        sleep(1)
        for j in num[i]:
            j.on()