Hirdetés

2024. május 4., szombat

Gyorskeresés

Téma összefoglaló

Téma összefoglaló

  • Utoljára frissítve: 2017-01-23 09:15:11

LOGOUT.hu

Huawei P9-P9 Lite OFF topik

Összefoglaló kinyitása ▼

Hozzászólások

(#814) petya220 válasza MK VII (#813) üzenetére


petya220
senior tag

Én ezen haltam ki..

Valaki programozó közülünk rajtam, és Cunaján kívül?

Hogy tudok egy tömb-be parancsokat dobálni, értékek helyett? :W

Csak,hogy ne legyen ilyen hosszú a programom: (ez még hosszabb lesz...)
import time
import RPi.GPIO as GPIO
GPIO.cleanup()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
channel = [17,18,22,27]
GPIO.setup(channel, GPIO.OUT)
time.sleep(0.5)
x=1
while True:
print "0"
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "1"
GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "2"
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.HIGH)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "3"
GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.HIGH)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "4"
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "5"
GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "6"
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.HIGH)
GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "7"
GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.HIGH)
GPIO.output(27, GPIO.HIGH)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)
print "8"
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.HIGH)
time.sleep(0.5)
print "9"
GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.HIGH)
print "clean"
time.sleep(0.5)
GPIO.cleanup()

Ezt a 4 sort:
GPIO.output(17, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
GPIO.output(27, GPIO.LOW)
GPIO.output(22, GPIO.LOW)
time.sleep(0.5)

belerakni egy kis tömbbem és 4 sor helyett, csak egy tömb nvevet kellene meghívnom, sokkal jobb lenne. :D ötlet?

[ Szerkesztve ]

"Neked is pörög az agyad a szarokon, amíg a mosoly a szádra kanyarodik."

Copyright © 2000-2024 PROHARDVER Informatikai Kft.