Ejemplo n.º 1
0
def scan(S):
    curr = GPIO.input(S)
    if curr != 0:  # For python 3.5
        # if curr ==0: # For python 2.7
        return S
    else:
        return 0
Ejemplo n.º 2
0
def Main():
    try:
        #====================================================
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(2, GPIO.OUT)
        GPIO.setup(3, GPIO.OUT)
        GPIO.setup(4, GPIO.OUT)
        GPIO.setup(5, GPIO.OUT)
        GPIO.setup(21, GPIO.IN)
        while (True):
            a = GPIO.input(21)
            if a == GPIO.HIGH:
                GPIO.output(2, GPIO.HIGH)
                time.sleep(0.5)
                GPIO.output(2, GPIO.LOW)
                GPIO.output(3, GPIO.HIGH)
                time.sleep(0.5)
                GPIO.output(3, GPIO.LOW)
                GPIO.output(4, GPIO.HIGH)
                time.sleep(0.5)
                GPIO.output(4, GPIO.LOW)
                GPIO.output(5, GPIO.HIGH)
                time.sleep(0.5)
                GPIO.output(5, GPIO.LOW)


#=====================================================
    except Exception as ex:
        traceback.print_exc()
Ejemplo n.º 3
0
def setupGPIO():
	try:
		#GPIO.setmode(GPIO.BOARD) 		# sets input to unified board pin numbers
		GPIO.setmode(GPIO.BCM)			# sets input to chip numbers, can differ per poard type

		GPIO.setwarnings(False)

		GPIO.setup(4, GPIO.OUT)
		GPIO.setup(17, GPIO.OUT, initial = GPIO.LOW)
		GPIO.setup(18, GPIO.OUT, initial = GPIO.LOW)
		GPIO.setup(21, GPIO.OUT, initial = GPIO.LOW)
		GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
		GPIO.setup(15, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
		GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
		GPIO.setup(26, GPIO.IN)

		while(True):
			if (GPIO.input(23) == False):
				GPIO.output(4,GPIO.HIGH)
				GPIO.output(17,GPIO.HIGH)
				time.sleep(1)

			if (GPIO.input(15) == True):
				GPIO.output(18,GPIO.HIGH)
				GPIO.output(21,GPIO.HIGH)
				time.sleep(1)

			if (GPIO.input(24) == True):
				GPIO.output(18,GPIO.LOW)
				GPIO.output(21,GPIO.LOW)
				time.sleep(1)

			if (GPIO.input(26) == True):
				GPIO.output(4,GPIO.LOW)
				GPIO.output(17,GPIO.LOW)
				time.sleep(1)

	except Exception as ex:
		traceback.print_exc()
	finally:
		GPIO.cleanup() #this ensures a clean exit
Ejemplo n.º 4
0
def Main():
    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(4, GPIO.OUT)
        GPIO.setup(17, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(18, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(21, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(26, GPIO.IN)

        while (True):
            if (GPIO.input(23) == False):
                GPIO.output(4, GPIO.HIGH)
                GPIO.output(17, GPIO.HIGH)
                time.sleep(1)

            if (GPIO.input(15) == True):
                GPIO.output(18, GPIO.HIGH)
                GPIO.output(21, GPIO.HIGH)
                time.sleep(1)

            if (GPIO.input(24) == True):
                GPIO.output(18, GPIO.LOW)
                GPIO.output(21, GPIO.LOW)
                time.sleep(1)

            if (GPIO.input(26) == True):
                GPIO.output(4, GPIO.LOW)
                GPIO.output(17, GPIO.LOW)
                time.sleep(1)

    except Exception as ex:
        traceback.print_exc()
    finally:
        GPIO.cleanup()  #this ensures a clean exit
Ejemplo n.º 5
0
def Main():

    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # Kasa Açıldı
        GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # Ev Kapısı Açıldı
        GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # Araba Açık

        GPIO.setup(25, GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)  # Araba Kapısı Kapandı
        GPIO.setup(16, GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)  # Ev Kapısı Kapandı
        GPIO.setup(8, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)  # Kasa Kapandı

        GPIO.setup(4, GPIO.OUT,
                   initial=GPIO.HIGH)  # Kasa Açık 1, Kasa Kapalı 0
        GPIO.setup(9, GPIO.OUT, initial=GPIO.LOW)  # Ev Açık 1, Ev Kapalı 0
        GPIO.setup(17, GPIO.OUT,
                   initial=GPIO.HIGH)  # Araba Açık 1, Araba Kapalı 0

        GPIO.setup(19, GPIO.OUT, initial=GPIO.LOW)  # Nem kontrol

        GPIO.output(4, GPIO.LOW)
        GPIO.output(9, GPIO.LOW)
        GPIO.output(17, GPIO.LOW)
        Kasakapaliguncelle()
        Evkapaliguncelle()
        Arabakapaliguncelle()

        while (True):

            if (GPIO.input(14) == True):
                GPIO.output(4, GPIO.HIGH)
                Kasaacikguncelle()

            if (GPIO.input(8) == True):
                GPIO.output(4, GPIO.LOW)
                Kasakapaliguncelle()

            if (GPIO.input(15) == True):
                GPIO.output(9, GPIO.HIGH)
                Evacikguncelle()

            if (GPIO.input(16) == True):
                GPIO.output(9, GPIO.LOW)
                Evkapaliguncelle()

            if (GPIO.input(18) == True):
                GPIO.output(17, GPIO.HIGH)
                Arabaacikguncelle()

            if (GPIO.input(25) == True):
                GPIO.output(17, GPIO.LOW)
                Arabakapaliguncelle()

        con.close()
    except Exception as ex:
        traceback.print_exc()
    finally:
        GPIO.cleanup()
Ejemplo n.º 6
0
        return rndhmp3(previoush)
    else:
        return randomfile


def rndmp3(previous):
    pattern = "/home/pi/or/mp3/*.mp3"  # (or "*.*")
    randomfile = random.choice(glob.glob(pattern))
    if randomfile == previous:
        return rndhmp3(previous)
    else:
        return randomfile


while True:
    input_state = GPIO.input(18)
    if input_state == False:
        print('Button Pressed')
        random.seed(datetime.now())
        print(random.seed)
        time.sleep(0.2)
        file = rndhmp3(previoush)
        previous = file
        print("1111111")
        print(file)
        os.system('mpg123 ' + file)
        print('Button Stoped')

    input_state = GPIO.input(23)
    if input_state == False:
        random.seed(time.time())
Ejemplo n.º 7
0
##import RPi.GPIO as GPIO
from EmulatorGUI import GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
GPIO.setup(15, GPIO.IN)

while True:
    if GPIO.input(14):
        GPIO.output(15, False)
    else:
        GPIO.output(15, True)
Ejemplo n.º 8
0
from EmulatorGUI import GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN)
GPIO.setup(7, GPIO.OUT)

while True:
    if GPIO.input(3):
        GPIO.output(7, GPIO.LOW)
    else:
        GPIO.output(7, GPIO.HIGH)
    smsText = 'If this SMS reaches to you then congratulations! Our SMS system is working!!---hafiz031'
    smsType = 'TEXT'

    maskName = ''
    campaignName = ''

    client.service.OneToOne(userName,password,recipientNumber,smsText,smsType,maskName,campaignName)

 
if __name__ == '__main__':
    GPIO.setup(GPIO_BEGIN_PIN, GPIO.IN)
    GPIO.setup(GPIO_END_PIN, GPIO.IN)
    while 1:
        start_time, end_time = 0, 0
        
        while GPIO.input(GPIO_BEGIN_PIN) == GPIO.LOW:
            time.sleep(0.001)
            start_time = time.time()
        end_time = 0
     
        while GPIO.input(GPIO_END_PIN) == GPIO.LOW and time.time()-start_time < TIMEOUT:
            time.sleep(0.001)
        else:
            end_time = time.time()
        if(start_time!=end_time):
            speed = DISTANCE / (end_time - start_time)
            if(speed>5):
                    print("Speed: %.20f cm/s" % speed)
                    if(speed>MAX_ALLOWED_SPEED):
                        informPCR()
Ejemplo n.º 10
0
#esta activacion en la resistencia pin 23 con PUD_UP
#esto intrumpe tensión con voltaje 3.3v
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#  configuramos el pin 23 como salida para el led
GPIO.setup(24, GPIO.OUT)
# definimos dos variables para guardar el estado del led
# por defecto el estado del led es False (apagado)
switch_state = False
# por defecto el estado anterior es True (encendido)
old_input_state = True  # activada
# bucle infinito que recoge el estado del pin18
# cada vez que presionamos el botón,el estado del switch
# alterna entre True/False
while True:
    # guardo en una variable el estado del pin
    new_input_state = GPIO.input(23)
    # si el estado es False (presionado),y el estado
    # anterior es True cambiamos el valor del switch
    if new_input_state == False and old_input_state == True:
        switch_state = not switch_state
        ##print('Boton presionado')
        ##print(switch_state)

        ########################PROCESO DE PETICION
        if switch_state == True:

            url = "https://gopidiego.site/api/auth/token"
            #url = "http://3.139.21.168:8069/api/auth/token"

            payload = '[email protected]&password=amorbb123&db=pruebas'
            headers = {'Content-Type': 'application/x-www-form-urlencoded'}
Ejemplo n.º 11
0
 def scan(self):
     curr = GPIO.input(self._pin)
     if curr == 0:  # For python 2.7
         return self._pin
     else:
         return 0