Example #1
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()
Example #2
0
def Main():
    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup("P8_7", GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup("P8_8", GPIO.IN, initial=GPIO.LOW)

        # 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):
            pass
            # 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
Example #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
Example #4
0
    elif req.door_id == 3:
        GPIO.output(4, GPIO.HIGH)
        time.sleep(1)
        GPIO.output(4, GPIO.LOW)

    return True


def door_server():
    rospy.init_node('door_server')
    s = rospy.Service('door', opendoor, handle_door)
    rospy.loginfo("ready to open doors ")
    rospy.spin()


if __name__ == "__main__":
    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(2, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(3, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(4, GPIO.OUT, initial=GPIO.LOW)

        door_server()
    except Exception as ex:
        traceback.print_exc()
    finally:
        GPIO.cleanup()  #this ensures a clean exit
Example #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()