Exemplo n.º 1
0
def sangDuoiTraiPhai():
    for pin in reversed(pins):
        GPIO.output(pin, True)
        sleep(blink_delay)
        GPIO.output(pin, False)
        sleep(blink_delay)
    tatAll()
Exemplo n.º 2
0
def sangGiuaRa():
    for pin in range(0, 5):
        GPIO.output(pins, True)
        sleep(blink_delay)
        GPIO.output(pins, False)
        sleep(blink_delay)
    tatAll()
Exemplo n.º 3
0
def sangDuoiPhaiTrai():
    for pin in pins:
        GPIO.output(pin, True)
        sleep(blink_delay)
        GPIO.output(pin, False)
        sleep(blink_delay)
    tatAll()
Exemplo n.º 4
0
def action_toggle() -> None:
    button = LED(power_pin)
    if REAL_ACTION == True:
        GPIO.output(power_pin, 1)
        sleep(1.5)
        GPIO.output(power_pin, 0)
        sleep(1)
    logger.debug("Tried Power TOGGLE")
    return
Exemplo n.º 5
0
Arquivo: LCD.py Projeto: yashb81/Code
    def __setGPIODataBits(self,data, instructie):
        x = data
        deel1 = x & 0xF0
        filter = 0x80

        if instructie:
            self.__eHoogInstructie()
        else:
            self.__eHoogData()

        for i in range(0, 4):
            deel1 = data & filter
            GPIO.output(self.__pins[i], deel1)
            filter >>= 1

        if instructie:
            self.__eLaagInstructie()
        else:
            self.__eLaagData()

        deel2 = x & 0x0F
        deel2 = deel2 << 4

        if instructie:
            self.__eHoogInstructie()
        else:
            self.__eHoogData()

        for i in range(0, 4):
            deel2 = data & filter
            GPIO.output(self.__pins[i], deel2)
            filter >>= 1

        if instructie:
            self.__eLaagInstructie()
        else:
            self.__eLaagData()
Exemplo n.º 6
0
Arquivo: LCD.py Projeto: yashb81/Code
 def Reset(self):
     self.__eHoogInstructie()
     GPIO.output(self.__RS, GPIO.LOW)
     GPIO.output(self.__RW, GPIO.LOW)
     GPIO.output(self.__DB7, GPIO.LOW)
     GPIO.output(self.__DB6, GPIO.LOW)
     GPIO.output(self.__DB5, GPIO.HIGH)
     GPIO.output(self.__DB4, GPIO.HIGH)
     self.__eLaagInstructie()
     self.__eHoogInstructie()
     GPIO.output(self.__DB7, GPIO.HIGH)
     GPIO.output(self.__DB6, GPIO.LOW)
     GPIO.output(self.__DB5, GPIO.HIGH)
     GPIO.output(self.__DB4, GPIO.HIGH)
     self.__eLaagInstructie()
Exemplo n.º 7
0
import RPi._GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

Output Pis = [17,22,25,26]

for items in Outputs:
    GPIO.setup(items,GPIO.OUT)
    GPIO.output(items,True)
    time.sleep(25)
    GPIO.cleanup()
Exemplo n.º 8
0
import RPi._GPIO as GPIO
from time import sleep
pins = [14, 15, 18, 23, 24]
blink_delay = 0.5

GPIO.setmode(GPIO.BCM)
for pin in pins:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, False)


def tatAll():
    for pin in pins:
        GPIO.output(pin, False)
    sleep(blink_delay)


def sangGiuaRa():
    for pin in range(0, 5):
        GPIO.output(pins, True)
        sleep(blink_delay)
        GPIO.output(pins, False)
        sleep(blink_delay)
    tatAll()


def chopTat():
    for pin in pins:
        GPIO.output(pin, True)
    sleep(blink_delay)
    tatAll()
Exemplo n.º 9
0
    def run(self):
        GPIO.setup(A0Mux, GPIO.OUT)
        GPIO.setup(A1Mux, GPIO.OUT)
        GPIO.setup(muxEnable, GPIO.OUT)

        GPIO.setup(A0, GPIO.OUT)
        GPIO.setup(A1, GPIO.OUT)
        GPIO.setup(A2, GPIO.OUT)

        GPIO.output(muxEnable, False)

        thread2.start()
        time.sleep(2)

        print("Enable #1")
        GPIO.output(muxEnable, True)
        GPIO.output(A0Mux, False)
        GPIO.output(A1Mux, False)

        # 000
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #001
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #010
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #011
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #100
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #101
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #110
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(1)

        #111
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(2)

        print("Enable #2")
        GPIO.output(muxEnable, True)
        GPIO.output(A0Mux, True)
        GPIO.output(A1Mux, False)
        # 000
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #001
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #010
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #011
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #100
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #101
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #110
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(1)

        #111
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(2)
        print("Enable #3")
        GPIO.output(muxEnable, True)
        GPIO.output(A0Mux, False)
        GPIO.output(A1Mux, True)

        # 000
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #001
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #010
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #011
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #100
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #101
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #110
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(1)

        #111
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, True)
        time.sleep(2)

        print("Enable #4")
        GPIO.output(muxEnable, True)
        GPIO.output(A0Mux, True)
        GPIO.output(A1Mux, True)

        # 000
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #001
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, False)

        time.sleep(1)

        #010
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #011
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, False)

        time.sleep(1)

        #100
        GPIO.output(A0, False)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #101
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        time.sleep(1)

        #110
        GPIO.output(A0, False)
        GPIO.output(A1, True)
        GPIO.output(A2, True)

        time.sleep(1)

        #111
        GPIO.output(A0, True)
        GPIO.output(A1, True)
        GPIO.output(A2, True)
        time.sleep(2)

        GPIO.output(muxEnable, False)

        print("Test Completed!")
        q.put(_sentinel)
Exemplo n.º 10
0
Arquivo: LCD.py Projeto: yashb81/Code
 def FunctionSet(self):
     self.__eHoogInstructie()
     GPIO.output(self.__RS, GPIO.LOW)
     GPIO.output(self.__RW, GPIO.LOW)
     GPIO.output(self.__DB7, GPIO.LOW)
     GPIO.output(self.__DB6, GPIO.LOW)
     GPIO.output(self.__DB5, GPIO.HIGH)
     GPIO.output(self.__DB4, GPIO.LOW)
     self.__eLaagInstructie()
     time.sleep(self.__delay_instructie)
Exemplo n.º 11
0
Arquivo: LCD.py Projeto: yashb81/Code
 def __eHoogData(self):
     GPIO.output(self.__E, 1)
     GPIO.output(self.__RS, 1)
     GPIO.output(self.__RW, 0)
Exemplo n.º 12
0
    def run(self):
        GPIO.setup(A0Mux, GPIO.OUT)
        GPIO.setup(A1Mux, GPIO.OUT)
        GPIO.setup(muxEnable, GPIO.OUT)

        GPIO.setup(A0, GPIO.OUT)
        GPIO.setup(A1, GPIO.OUT)
        GPIO.setup(A2, GPIO.OUT)

        GPIO.output(muxEnable, False)

        thread2.start()
        time.sleep(2)

        print("Enable #4")
        GPIO.output(muxEnable, True)
        GPIO.output(A0Mux, True)
        GPIO.output(A1Mux, True)

        time.sleep(1)

        #101 (Y5)
        GPIO.output(A0, True)
        GPIO.output(A1, False)
        GPIO.output(A2, True)

        print("Charge On!")
        q.put(_sentinel)
Exemplo n.º 13
0
def sangDanTraiPhai():
    for pin in pins:
        GPIO.output(pin, True)
        sleep(blink_delay)
    tatAll()
Exemplo n.º 14
0
def chopTat():
    for pin in pins:
        GPIO.output(pin, True)
    sleep(blink_delay)
    tatAll()
Exemplo n.º 15
0
def tatAll():
    for pin in pins:
        GPIO.output(pin, False)
    sleep(blink_delay)
Exemplo n.º 16
0
Arquivo: LCD.py Projeto: yashb81/Code
 def __eHoogInstructie(self):
     GPIO.output(self.__E, 1)
     GPIO.output(self.__RS, 0)
     GPIO.output(self.__RW, 0)
Exemplo n.º 17
0
Arquivo: LCD.py Projeto: yashb81/Code
 def __eLaagInstructie(self):
     GPIO.output(self.__E, 0)
     GPIO.output(self.__RS, 0)
     GPIO.output(self.__RW, 0)
Exemplo n.º 18
0
def setup_pins():
    GPIO.setmode(GPIO.BCM)
    # , pull_up_down=GPIO.PUD_DOWN
    GPIO.setup(power_pin, GPIO.OUT)
    GPIO.output(power_pin, 1)
Exemplo n.º 19
0
Arquivo: LCD.py Projeto: yashb81/Code
 def __eLaagData(self):
     GPIO.output(self.__E, 0)
     GPIO.output(self.__RS, 1)
     GPIO.output(self.__RW, 0)
Exemplo n.º 20
0
def relay230V(always_on,gas_on,CO2,CO):
    if ((always_on == "1")) or ((gas_on == "1") and ((CO2 > 2000) or (CO != "geen CO"))):
        GPIO.output(12,GPIO.HIGH)
    else:
        GPIO.output(12,GPIO.LOW)
    return
Exemplo n.º 21
0
Arquivo: LCD.py Projeto: yashb81/Code
 def Clear_Display(self):
     self.__eHoogInstructie()
     GPIO.output(RS, GPIO.LOW)
     GPIO.output(self.__RW, GPIO.LOW)
     GPIO.output(self.__DB7, GPIO.LOW)
     GPIO.output(self.__DB6, GPIO.LOW)
     GPIO.output(self.__DB5, GPIO.LOW)
     GPIO.output(self.__DB4, GPIO.LOW)
     self.__eLaagInstructie()
     self.__eHoogInstructie()
     GPIO.output(self.__DB7, GPIO.LOW)
     GPIO.output(self.__DB6, GPIO.LOW)
     GPIO.output(self.__DB5, GPIO.LOW)
     GPIO.output(self.__DB4, GPIO.HIGH)
     self.__eLaagInstructie()
     time.sleep(self.__delay_instructie)
Exemplo n.º 22
0
def relayVentilator(ventWaarde):
    if ((ventWaarde == "1")):
        GPIO.output(17,GPIO.HIGH)
    else:
        GPIO.output(17,GPIO.LOW)
    return
import RPi._GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

ControlPin = [17, 18, 27, 22]

for pin in ControlPin:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.setup(pin, GPIO.LOW)

seq = [[1, 0, 0, 0], [1, 1, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 0],
       [0, 0, 1, 1], [0, 0, 0, 1], [1, 0, 0, 1]]

for i in range(512):
    for halfstep in range(8):
        for pin in range(4):
            a = ControlPin[pin], seq[halfstep][pin]
            GPIO.output(ControlPin[pin], seq[halfstep][pin])
            time.sleep(0.001)

GPIO.cleanup()
Exemplo n.º 24
0
# Chuong trinh chop tat led i thoi gian ngan, mo ta pwm

import RPi._GPIO as GPIO
from time import sleep

pin = 14  #khai bao pin out
GPIO.setmode(GPIO.BCM)  #khai bao kieu pin
GPIO.setup(pin, GPIO.OUT)  #setup pin output

try:
    while True:
        GPIO.output(pin, True)  #bat led
        sleep(0.001)  #delay 1ms
        GPIO.output(pin, False)  #tat led
        sleep(0.009)  #delay 1ms

except KeyboardInterrupt:  #thoat chuong trinh khi an Ctrl + C
    print(" Thoat chuong trinh")
    GPIO.cleanup()