Esempio n. 1
0
def FindDistance4():

    GPIO.output(trigS4, False)
    time.sleep(1)
    GPIO.output(trigS4, True)
    time.sleep(0.00001)
    GPIO.output(trigS4, False)
    while GPIO.input(echoS4) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS4) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance4 = pulse * 17150
    distance4 = round(distance, 2)
    if distance4 < 10:
        distance4 = 1
        status4 = "slot 4 is full"
        return distanc4

    else:
        distance4 = 0
        status4 = "slot 4 is empty"
        return distance4

    return status4
Esempio n. 2
0
def FindDistance6():

    GPIO.output(trigS6, False)
    time.sleep(1)
    GPIO.output(trigS6, True)
    time.sleep(0.00001)
    GPIO.output(trigS6, False)
    while GPIO.input(echoS6) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS6) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance6 = pulse * 17150
    distance6 = round(distance, 2)
    if distance6 < 10:
        distance6 = 1
        status6 = "slot 6 is full"
        return distance6

    else:
        distance6 = 0
        status6 = "slot 6 is empty"
        return distance6

    return status6
Esempio n. 3
0
def FindDistance3():

    GPIO.output(trigS3, False)
    time.sleep(1)
    GPIO.output(trigS3, True)
    time.sleep(0.00001)
    GPIO.output(trigS3, False)
    while GPIO.input(echoS3) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS3) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance3 = pulse * 17150
    distance3 = round(distance, 2)
    if distance3 < 10:
        distance3 = 1
        status3 = "slot 3 is full"
        return distance3

    else:
        distance3 = 0
        status3 = "slot 3 is empty"
        return distance3

    return status3
Esempio n. 4
0
def FindDistance2():

    GPIO.output(trigS2, False)
    time.sleep(1)
    GPIO.output(trigS2, True)
    time.sleep(0.00001)
    GPIO.output(trigS2, False)
    while GPIO.input(echoS1) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS2) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance2 = pulse * 17150
    distance2 = round(distance, 2)
    if distance2 < 10:
        distance2 = 1
        status2 = "slot 2 is full"
        return distance2

    else:
        distance2 = 0
        status2 = "slot 2 is empty"
        return distance2

    return status2
Esempio n. 5
0
def FindDistance1():

    GPIO.output(trigS1, False)
    time.sleep(1)
    GPIO.output(trigS1, True)
    time.sleep(0.00001)
    GPIO.output(trigS1, False)
    while GPIO.input(echoS1) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS1) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance1 = pulse * 17150
    distance1 = round(distance, 2)
    if distance1 < 10:
        distance1 = 1
        status1 = "slot 1 is full"
        return distance1

    else:
        distance1 = 0
        status1 = "slot 1 is empty"
        return distance1

    return status1
Esempio n. 6
0
def FindDistance5():

    GPIO.output(trigS5, False)
    time.sleep(1)
    GPIO.output(trigS5, True)
    time.sleep(0.00001)
    GPIO.output(trigS5, False)
    while GPIO.input(echoS5) == 0:
        pulse_start = time.time()
    while GPIO.input(echoS5) == 1:
        pulse_end = time.time()

    pulse = pulse_end - pulse_start
    distance5 = pulse * 17150
    distance5 = round(distance, 2)
    if distance5 < 10:
        distance5 = 1
        status5 = "slot 5 is full"
        return distance5

    else:
        distance5 = 0
        status5 = "slot 5 is empty"
        return distance5

    return status5
def distance():
    GPIO.output(trig, True)
    time.sleep(0.00001)
    GPIO.output(trig, False)

    while GPIO.input(echo) == 0:
        pulse_start = time.time()

    while GPIO.input(echo) == 1:
        pulse_end = time.time()

    pulse_duration = pulse_end - pulse_start
    d = pulse_duration * 17150
    d = round(distance, 2)
    return d
Esempio n. 8
0
    def run(self):
	gpio.output(TRIG, False)
	print "Waiting For Sensor To Settle"
	time.sleep(2)

	gpio.output(TRIG, True)
	time.sleep(0.00001)
	gpio.output(TRIG, False)

	while gpio.input(ECHO) == 0:
	    pulse_start = time.time()

	while gpio.input(ECHO) == 1:
  	    pulse_end = time.time()
	pulse_duration = pulse_end - pulse_start
	distance = pulse_duration * 17150
	self.dist = round(distance, 2)
	return self.dist
Esempio n. 9
0
def send(interface):
    while True:
        try:
            #mensagem: leitura do botão
            message = gpio.input(18)
            interface.sendall(message.encode("utf-8"))
        except socket.error:
            break
    print("Envio de mensagens encerrado!")
Esempio n. 10
0
def subplot(val1,val2):
fig = plt.figure()
sb1 = fig.add_subplot(1,2,1)
x = np.arange(len(val1))
sb1.plot(x, val1, c='r')
sb1.set_title('Encoder Data')
sb1.set_xlabel('Time')
sb1.set_ylabel('State')

sb2 = fig.add_subplot(1,2,2)
x = np.arange(len(val2))
sb2.plot(x, val1, c='r')
sb2.set_title('Encoder Data')
sb2.set_xlabel('Time')
sb2.set_ylabel('State')

# Display all plots

########### Main Code #########
init()

counterBR = np.uint64(0)
counterFL = np.uint64(0)


buttonBR = int(0)
buttonFL = int(0)

# Initialize pwm signal to control motor
pwm1 = gpio.PWM(31,50) # BackRight
pwm2 = gpio.PWM(37,50) # FrontLeft
val = 22
pwm1.start(val)
pwm2.start(val)
time.sleep(0.1)

for i in range(0, wheelRev):  # from 0 to wheelrevs for 10 meters which is 48.97 
	print("counterBR = ", counterBR,
		  "counterFL = ", counterFL, 
	      "BR state: ", gpio.input(12), 
	      "FL state: ", gpio.input(7)) 

	if int(gpio.input(12) != int(buttonBR)):
		button = int(gpio.input(12)) #holds the state
		statesRight.append(button)
		counter += 1

	if int(gpio.input(7) != int(buttonFL)):
		button = int(gpio.input(7)) #holds the state
		statesLeft.append(button)
		counter += 1
		
	pwm1.stop()
	pwm2.stop()
	gameover()
	saveToFile("enc03Right.txt", statesRight)
	saveToFile("enc03Left.txt" statesLeft)
	subplot(statesRight, statesLeft)
	print("Thanks for playing !")
Esempio n. 11
0
    def run(self):
        while (True):
            row = db.executeQuery("Select is_motion from house where id = 1")
            if row is not None:
                is_motion = row.fetchone()[0]
                if (is_motion == 1):
                    #GPIO.add_event_detect(SENSOR_PIN,GPIO.RISING,callback=motionDetect)
                    if (GPIO.input(10)):
                        RaspberryPi.changeStateMotion(16, 0)
                        RaspberryPi.changeStateMotion(18, 0)
                        RaspberryPi.changeStateMotion(2, 0)

                    else:
                        RaspberryPi.changeStateMotion(16, 1)
                        RaspberryPi.changeStateMotion(18, 1)
                        RaspberryPi.changeStateMotion(2, 1)
Esempio n. 12
0
import Rpi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)


def push_button(channel):
    print "Interrupt!"


GPIO.add_event_detect(11, GPIO.FALLING, callback=push_button)

while True:
    #   print "waiting..."
    input_state = GPIO.input(11)
    print input_state
    #   if input_state == False:
    #        button down
    #       print "FAlSE"
    #   else:
    #       button up
    #       print "TRUE"
    time.sleep(1)
Esempio n. 13
0
import Rpi.GPIO as GPIO
GPIO.setup(18, GPIO.OUT)
GPIO.setup(11, GPIO.IN)
while True:
	if GPIO.input(11):
		GPIO.output(18, True)
	else:
		GPIO.output(18, False)
Esempio n. 14
0
#to excute we must use sudo pyhon3 ---.py
import Rpi.GPIO as GPIO
# use board numbering (1,2,3,--)
# mainly use it as other can diffe from one module to another
GPIO.setmode(GPIO.BOARD)
# use SoC numbering (GPIO1,GPIO2,GPIO3,--)
GPIO.setmode(GPIO.BCM)
# sets direction GPIO.setup(pin_number,direction)
# GPIO.OUT-->output ,GPIO.IN-->input
GPIO.setup(13,GPIO.OUT)
GPIO.setup(13,GPIO.IN)
# assign output value GPIO.output(pin_number,value)
# True-->1"3.3v" ,False-->0"0v"
GPIO.output(13,True)
GPIO.output(13,False)
# read input pins GPIO.input(pin_number)
# returns True or False
value = GPIO.input(13)
Esempio n. 15
0
import os
from time import sleep

import Rpi.GPIO as GPIO


GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)

while True:
        if(GPIO.input(23) == False):
                os.system('amixer -q sset Master 3%+')
        if(GPIO.input(24) == False):
                os.system('amixer -q sset Master 3%-')
        if(GPIO.input(25) == False):
                os.system('mpc clear')
                
        sleep(0.1)
def getStart(pin):
    while GPIO.input(pin) == 0:
        start_time = time.time()
    return start_time
Esempio n. 17
0
import Rpi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(12,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)

while True:

	if(GPIO.input(12)==1):
		print 'Motion Detected'
		

	time.sleep(.1)
	
Esempio n. 18
0
# this python file use for insert sensor data in database

#import MyDB connection module
import MyDB
db = MyDB.DB()
import Rpi.GPIO as GPIO
import time

sensorPin1 = 18 #Broadcom pin 18
#pin setup:
GPIO.setmode(GPIO.BCM) #Broadcom pin numbering scheem
GPIO.setup(sensorPin1, GPIO.IN, pull_up_down=GPIO.PUD_UP) # sensor pin set as input
user_id = 1023
data = [user_id]

try:
    while 1:
        if GPIO.input(sensorPin1):
            db.execute("INSERT INTO Zones (user_id,zone1) \
                  VALUES (%s, NOW() )", [data]);

            db.commit()
            print "Records created successfully";
            db.close()

except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:

    GPIO.cleanup() # cleanup all GPIO
Esempio n. 19
0
humidity = sht1x.read_humidity()
    return humidity

def checkBarometer():
    bmp = BMP085(0x77)
    pressure = bmp.readPressure()
    pressure = pressure/100.0
    return pressure

def checkWindSpeed()
    prev_input = 0
    total = 0
    totalSpeed = 0
    current = time.time()
    for i in range(0, 900):
        input = GPIO.input(8)
        if ((not prev_input) and input):
            total = total + 1
        prev_input = input
        if total == 90:
            rps = (1/ (time.time()-current))
            speed = math.exp((rps + 0.95)/4.3)
            totalSpeed = totalSpeed + speed
            total = 0
            current = time.time()
    speed = totalSpeed / 10    #average speed out of ten turns
    return speed

def checkWindDirection()
    write_byte(0, 0b01110000)
    write_byte(0, 0b00100000)
Esempio n. 20
0
def ReadTriggerPin():
  return gpio.input(TRIGGER)
from Rpi import GPIO  #import GPIO Module
GPIO.setmode(GPIO.BOARD)  # Board Pin
GPIO.setwarnings(False)  # set Warnings
GPIO.setup(40, GPIO.IN)  #declare input pin
GPIO.setup(5, GPIO.OUT)  #declare output pin
while True:  #use to While loop
    a = GPIO.input(40)  #input pin
    if a == 1:  #condition
        GPIO.output(5, HIGH)  #Led On
    else:
        GPIO.output(5, LOW)  #Led Off
Esempio n. 22
0
gpio . setmode(gpio . BCM) # modo BCM de la raspberry pi (Broadcom soc channel)

gpio . setup(led1, gpio . out)  # configuramos los puertos conectados a los leds como salida

while True:                 # bucle infinito
    gpio . out(led1,True)              # encendemos el led
    sleep(1)                            # paus de un segundo
    gpio . output(led1 , False)         # apagamos el led1
    sleep(1)                            # pausa de un segundo

    ###########################################################################################
    

while true: 
    condicion = gpio.input(entrada)
    sleep(0.3)
    if condicion==True: # si se preciona es true . entra en esa linea 

        contador = contador + 1   #aumentamos la variable contador   
        # como solo tenemos un led , contador debe tomar los valores 0 , 1
        if contador = 2:
            contador=0 # pero usamos el 0 para apagar el led 
    if contador ==0:
        gpio.output(led1,False)               # apagamos el led1
    if contador==1:
        gpio.output(led1,True)                #  encendemos el led


        # ejercicio: con la primera pulsacion , encender solo el primer led 
        #            con la segunda pulsacion , ensencder solo el segundo led 
Esempio n. 23
0
 def action_event_registrar(gpio_pin):{
  if gpio_pin == Porta:{
   if gpio.input(gpio_pin) == 0:
    PortaEstado = "aberta";
   else:
    PortaEstado = "fechada";
   # if datetime.now()>PortaEvento:#esta aqui so para lembrar de como é a comparacao de datetime
   # if PortaEvento<(datetime.now()+timedelta(seconds=1)):#nao se pode comparar datetime com timedelta, mas pode-se somar.
   PortaEvento = datetime.now()
   #datahora = datetime.now()
   print "Houve um evento na porta (pino %d) e agora ela está %s \n" % gpio_pin, %PortaEstado
   print (PortaEvento)
  }
   
  if gpio_pin == Tranca:{
   if gpio.input(gpio_pin) == 0:
    TrancaEstado = "aberta";
   else:
    TrancaEstado = "fechada";
   # if datetime.now()>PortaEvento:#esta aqui so para lembrar de como é a comparacao de datetime
   # if PortaEvento<(datetime.now()+timedelta(seconds=1)):#nao se pode comparar datetime com timedelta, mas pode-se somar.
   TrancaEvento = datetime.now()
   #datahora = datetime.now()
   print "Houve um evento na tranca (pino %d) e agora ela está %s \n" % gpio_pin, %PortaEstado
   print (TrancaEvento)
  } 
 }
 
 def action_event_button(gpio_pin):{
  if TrancaEstado == "fechada":{
   if PortaEstado == "fechada":{
Esempio n. 24
0
 def action_event_registrar(gpio_pin):{
  if gpio_pin == Porta:{
   if gpio.input(gpio_pin) == 0:
    PortaEstado = "aberta";
   else:
Esempio n. 25
0
GPIO.setmode(GPIO.BCM)

TRIG = 12
ECHO = 24

GPIO.setup(TRIG, GPIO.OUT)
GPIO.output(TRIG, 0)

GPIO.setup(ECHO, GPIO.IN)

time.sleep(0.1)

print("Starting Measurement....")

GPIO.output(TRIG, 1)
time.sleep(0.00001)
GPIO.output(TRIG, 0)

while GPIO.input(ECHO) == 0:
    pass
start = time.time()

while GPIO.input(ECHO) == 1:
    pass
stop = time.time()

print(stop - start) * 17000

GPIO.cleanup()
    sht1x = SHT1x(dataPin, clkPin, SHT1x.GPIO_BOARD)
    humidity = sht1x.read_humidity()
    return humidity 
def checkBarometer():
    bmp = BMP085(0x77)
    pressure = bmp.readPressure()
    pressure = pressure/100.0
    return pressure 
def checkWindSpeed():
    prev_input = 0
    total = 0
    totalSpeed = 0
    current = time.time()

for i in range(0, 900):
    input = GPIO.input(8)
    if ((not prev_input) and input):
        total = total + 1
    prev_input = input
    if total == 90:
        rps = (1/ (time.time()-current))
        speed = math.exp((rps + 0.95)/4.3)
        totalSpeed = totalSpeed + speed
        total = 0
        current = time.time()
        speed = totalSpeed / 10    #average speed out of ten turns
        return speed 
def checkWindDirection():
    write_byte(0, 0b01110000)
    write_byte(0, 0b00100000)
    write_byte(0, 0b00000000)
Esempio n. 27
0
if __name__ == '__main__':
  gpsp = GpsPoller() # create the thread
  try:
    gpsp.start() # start it up
    while True:
      #It may take a second or two to get good data
      #print gpsd.fix.latitude,', ',gpsd.fix.longitude,'  Time: ',gpsd.utc
 
        os.system('clear')
	    latitude = gpsd.fix.latitude
	    longitude = gpsd.fix.longitude
	    time = gpsd.utc,' + ', gpsd.fix.time
	  
	  #GPIO read
	    GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	    button = GPIO.input(11)
	  
	  #if button is pressed than write to file
	    if button == False:
	        gpsdLog = open("GPSLOG.txt", "a")
	        print(latitude, sep = "*", end="\n",file=gpsdLog)
		    print(longitude, sep = "*", end="\n",file=gpsdLog)
		    print(time, sep = "*", end="\n",file=gpsdLog)
		    button = True
		    time.sleep(3) #delay
	    else:
            time.sleep(3) 
		    print("variables are resetting")
 
  except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
    print ("\nKilling Thread...")
Esempio n. 28
0
import Rpi.GPIO as gpio
import time

gpio.setmode(gpio, BCM)

trig = 21  #initialized trigger & echo pins
echo = 20
gpio.setup(trig, gpio.OUT)  #set trig pin as output
gpio.setup(echo, gpio.IN)  # set echo pin as Input

gpio.output(trig, False)  # clearing off the trigger pin
print("Waiting for sensor to settle")
time.sleep(2)

while (True):
    gpio.output(trig, True)  # line 16 to 18 creates a pulse
    time.sleep(0.0001)
    gpio.output(trig, False)
    while gpio.input(echo) == 0:  #used to mark start time
        pulse_start = time.time()
    while gpio.input(echo) == 1:  # used to mark end time
        pulse_end = time.time()
    pulse_duration = pulse_end - pulse_start
    distance = pulse_duration * 17150
    distance = round(distance, 2)
    print("Distance is" + distance + "cm")
Esempio n. 29
0
import Rpi.GPIO as GPIO
import time
import picamera
from time import sleep

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.IN)

api=ApiClient("2355dc90c5e93fc697295b33f9a6ed4e5003c2e1")

#create a "Variable" object

test_variable=api.get_variable("566993407625420e4e82690a")

while True:
	i=GPIO.input(11)
	i=0
	if i==1
		test_variable.save_value({'value':1})
		camera=picamera.PiCamera()
		camera.capture('suyash.jpg')

		camera.start_preview()
		camera.vflip=True
		camera.hflip=True
		camera.brightness=60
		
		sleep(10)

		i==0
def getEnd(pin):
    while GPIO.input(pin) == 1:
        end_time = time.time()
    return end_time
Esempio n. 31
0
	def read(self):
		"""
		Note: GPIO reads should be faster than network IO
		"""
		return GPIO.input(self.ch_port)
Esempio n. 32
0
def ReadTriggerPin():
    return gpio.input(TRIGGER)
Esempio n. 33
0
GPIO.setmode(GPIO.BCM)
GPIO_TRIGGER=18
GPIO_ECHO24

GPIO.setup(GPIO_TRIGGER,GPIO.OUT)
GPIO.setup(GPIO_-ECHO,GPIO.IN)

Def distance():
		GPIO.output(GPIO_TRIGGER,True)
		Time.sleep(0.0001)
		GPIO.output(GPIO_TRIGGER,False)

		StartTime=time.time()
		StopTime=time.time()

		while GPIO.input(GPIO_ECHO) == 0:
			StartTime = time.time()

		while GPIO.inut(GPIO_ECHO) ==1:
			StopTime=time.time()

		TimeElapsed=StopTime-StartTime
		distance=(TimeElapsed * 34300)/2
		Return distance

if__name__ == ‘__main__:
		try:
			while True:
				distance=distance()
				print(“Me91asured Distance=%.1f cm”%dist)
				time.sleep(1)
Esempio n. 34
0
import Rpi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

try:
    print "Push the button on the GPIO to start a game."
    print "Click the tiles to flip them.  After a short delay, they will flip back over."
    print "Don't click too fast.  You want to see what you flipped."

    while (True):
        if (GPIO.input(6) == GPIO.HIGH):
            import MemoryGame

except KeyboardInterrupt:
    GPIO.cleanup()
Esempio n. 35
0
last_state1 = True
last_state2 = True
last_state3 = True
last_state4 = True

input_state1 = True
input_state2 = True
input_state3 = True
input_state4 = True

quit_video = True

''' Main loop '''
while True:
	'''Read states of inputs'''
	input_state1 = GPIO.input(14)
	input_state2 = GPIO.input(15)
	input_state3 = GPIO.input(18)
	input_state4 = GPIO.input(23)
	quit_video = GPIO.input(24)

	'''If GPIO(14) is shorted to ground'''
	if input_state1 != last_state1:
		if (player and not input_state1):
			os.system('killall omxplayer.bin')
			omxc = Popen(['omxplayer', '-b', movie1])
			player = True
		elif not input_state1:
			omxc = Popen(['omxplayer', '-b', movie1])
			player = True
	
Esempio n. 36
0
import serial
import time
import Rpi.GPIO as GPIO
from rfid import readrfid
	from fire import locat
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(11,GPIO.IN)
	GPIO.setup(12,GPIO.IN)
	GPIO.setup(13,GPIO.IN)
	GPIO.setup(15,GPIO.IN)
	GPIO.setup(16,GPIO.IN)
GPIO.setup(18,GPIO.IN)
	while True:
	loc1= GPIO.input(11)
	loc2= GPIO.input(12)
	plant1= GPIO.input(13)
	plant2= GPIO.input(15)
	customer= GPIO.input(16)
park= GPIO.input(18)
	if plant1 == True:
	print(“Parcel has reached plant 1”)x=”a”
	y=readrfid()
	locat(x,y)
time.sleep(1)
	elif plant2 == True:
print(“Parcel has reached plant 2”)
	x=”b”
	y=readrfid()
	locat(x,y)
time.sleep(1)
	elif loc1 == True:
Esempio n. 37
0
# !/usr/bin/python3
# -- coding: UTF-8 --
# Author   :WindAsMe
# Date     :18-7-24 下午12:49
# File     :detectButton.py
# Location:/Home/PycharmProjects/..
import Rpi.GPIO as GPIO
import time

# Pin Definition
butPin = 12

# Pin Setup
GPIO.setmode(GPIO.BOARD)
GPIO.setup(butPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

print("Running...")

try:
    while True:
        if GPIO.input(butPin):
            print("Released!")
        else:
            print("Pressed!")
        time.sleep(0.25)
except KeyboardInterrupt:
    GPIO.cleanup()
    print("Terminal!")
Esempio n. 38
0
SatPMOn  = datetime.time(hour = 18)
SatPMOff = datetime.time(hour = 19)
SunAMOn  = datetime.time(hour = 6)
SunAMOff = datetime.time(hour = 7)
SunPMOn  = datetime.time(hour = 18)
SunPMOff = datetime.time(hour = 19)

# putting all the time in an array
onTimeAMOn = [MonAMOn, TueAMOn, WedAMOn, ThuAMOn, FriAMOn, SatAMOn, SunPMOn]
OnTimePM = [MonPMOn, TuePMOn, WedPMOn, ThuPMOn, FriPMOn, SatPMOn, SunPMOn]
OffTimeAM = [MonAMOff, TueAMOff, WedAMOff, ThuAMOff, FriAMOff, SatAMOff, SunAMOff]

# Start the loop that will run until you stop the program or turn off your Raspberry Pi.
 
while True:
    button = GPIO.input(17)
    #print('ttt')
    global state
    if button == 0:
        #print('button', button)
        state = 1
        #print('state', state)
    if state == 1:
        time.sleep(0.5)
        GPIO.output(24, True)
        GPIO.output(27, True)
        time.sleep(3600) #3600
        state = 0
        GPIO.output(24, False)
        GPIO.output(27, False)