Keresés

Új hozzászólás Aktív témák

  • petya220

    senior tag

    válasz MK VII #813 üzenetére

    É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."

  • bubus66

    nagyúr

    válasz MK VII #813 üzenetére

    ;] :C

    A Tűzoltók nem hősök, mert a hősök mind halottak. A Tűzoltó olyan ember, mint Te, csak képes oda adni az életét a Te életedért!

Új hozzászólás Aktív témák