Пример #1
0
    def __init__(self, input_pins, output_pins, keyboard_name, bouncetime, polarity = 0, *args, **kwargs):
        logger.debug("__init__(input_pins = %s, output_pins = %s, polarity = %s)",
                     input_pins, output_pins, polarity)
        self.keyboard_name = keyboard_name
        self._polarity = polarity
        self._InputPins = map(int, input_pins)
        self._OutputPins = map(int, output_pins)

        p.init()

        self.__listener = p.InputEventListener()
        for input_pin in self._InputPins:
            self.__listener.register(
                pin_num = input_pin,
                direction  = p.IODIR_BOTH,
                callback  = self.event_detect,
                settle_time = bouncetime / 1000 # from milliseconds to seconds
            )
            self._register_EVENTS_for_pin(input_pin, __name__)
        self.__listener.activate()

        # use set_output to register status @ dict self.__OutputStatus
        for output_pin in self._OutputPins:
            self.set_output(output_pin, 0, False)

        self.register_destroy_action()
Пример #2
0
 def init(self):
     app.logger.info("INIT PIFACE")
     try:
         piface.init()
         self.state = True
     except Exception as e:
         app.logger.error("SETUP PIFACE FAILD " + str(e))
         self.state = False
 def __init__(self, master):
     super(Application, self).__init__(master)  
     self.grid()
     self.master.title("LED Counting Game V1.0")
     # initialise the GUI window ready for user interaction
     self.create_widgets()
     # initialise the PiFace digital i/o package
     # so we can control the boards and hence the LEDs
     pfio.init(True,0,0)
Пример #4
0
  def read(self):
      """Read current state from the controller and return info"""
      # Initalize piface digital and list to store inputs
      p.init()    
      values = [0,0,0,0,0]
  
 
      for i in range(5):
          values[i] = p.digital_read(i)
               
      return values    
Пример #5
0
    def __init__(self, *av, **ad):
        comm.Comm.__init__(self, *av, **ad)
        self.board = 0
        self.listensd = {}

        self.send("!hello","CommPiFace")

        pifacedigitalio.init()

        self.pfd = pifacedigitalio.PiFaceDigital()
        self.listener = None
Пример #6
0
    def setUp(self):
        pifacedigitalio.init()
        self.direction = pifacedigitalio.IODIR_ON
        self.barriers = dict()
        self.board_switch_pressed = list()
        self.listeners = list()

        global pifacedigitals
        for p in pifacedigitals:
            self.barriers[p.hardware_addr] = threading.Barrier(2, timeout=10)
            listener = pifacedigitalio.InputEventListener(p.hardware_addr)
            listener.register(0, self.direction, self.interrupts_test_helper)
            self.listeners.append(listener)
Пример #7
0
def main():
    global last_tweet_id
    last_tweet_id = 0

    pifacedigitalio.init()
    robotchicken = RobotChicken()

    try:
        while True:
            say_latest_tweet(robotchicken)
            sleep(DELAY)
    except KeyboardInterrupt:
        pifacedigitalio.deinit()
def init(init_board=True):
    pfio.init(init_board)

    global proc_comms_q_to_em
    global proc_comms_q_from_em
    proc_comms_q_to_em   = Queue()
    proc_comms_q_from_em = Queue()

    # start the gui in another process
    global emulator
    emulator = Process(
            target=run_emulator,
            args=(sys.argv, proc_comms_q_to_em, proc_comms_q_from_em))
    emulator.start()
Пример #9
0
def main():
    piface.init()
    global screen
    pygame.init()
    if (not os.path.isdir(logo_path)):
        print "ERROR: tweetmachine dir not found in"
        print logo_path
        sys.exit(2)
    size = width, height = 600, 400
    screen = pygame.display.set_mode(size)
    pygame.mouse.set_visible(0)

    parser = OptionParser()
    parser.add_option("-t", "--twitter", dest="twitter", action="store_true",\
default=False, help= "start monitoring twitter feed")
    parser.add_option("-l", "--logo", dest="logo", action ="store_true",\
default=False, help= "display LowellMakes Logo")
    parser.add_option("-w", "--write",dest="text", default ='', help = "display\
text on the screen")
    parser.add_option("-a", "--auto", dest="loop", default =False, action ="store_true",\
help = "runs a loop, accepts input from the std_in")
    parser.add_option("-b", "--btn", dest="btn", default =False, action ="store_true", help = "polls the coin return button")
    (options,args)=parser.parse_args()

    if(options.twitter == True):
        displayTwitter()
    elif(options.logo == True):
        displayLogo()
    elif(not(options.text is '')):
        displayText(options.text, 100, 30, (200,200,1), True )
    elif(options.btn == True):
        while(True):
            if piface.digital_read(0):
                displayTwitter()
                displayLogo()
            elif piface.digital_read(2):
                break;
    elif(options.loop == True):
        end = True
        while(end):
            usr_input=raw_input("enter choice l=logo,t=twitter,e=exit\n")
            if usr_input is "t":
                displayTwitter()
            elif usr_input is "l":
                displayLogo()
            elif usr_input is "e":
                break;
            time.sleep(1)
    time.sleep(1)
Пример #10
0
    def run(self):
        pfio.init()
        self.attach_feeder()
        self.load_YAML()
        while not self.done:
            # --- Main event loop
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.done = True


            # --- Limit to 60 frames per second
            self.clock.tick(1)

        # Close the window and quit.
        pygame.quit()
Пример #11
0
    def run(self):
        print "begin"
        conn = sqlite3.connect('/var/sqlite/garagemon.db')
        ## I'm alive! Determine the last known door position
        c.execute('SELECT current_position FROM position')
        status = c.fetchone()
        doorState = "unknown"
        doorOpenCtr = 0
        piface.init()
        while True:
            ## Ping the router to keep the wifi alive
            response = os.system("ping -c 1 " + "10.0.0.1")

            if doorState is "open" and doorOpenCtr is 10:
                curl.setopt(curl.URL, 'http://localhost/evaluatestillopen')
                curl.perform()                            

            piface.digital_write_pullup(0, 1)
            ## Door open state
            if (piface.digital_read(0) == 0 and doorState is "closed") or doorState is "unknown":
                curl.setopt(curl.URL, 'http://localhost/evaluateopen')
                curl.perform() 
                doorState = "open";
                ## Set the little led lights
                # piface.digital_write(1, 0)
                # piface.digital_write(0, 1)
                doorOpenCtr = 0;
            ## Door closed state
            elif (piface.digital_read(0) > 0  and doorState is "open") or doorState is "unknown":
                curl.setopt(curl.URL, 'http://localhost/evaluateclosed')
                curl.perform()
                doorState = "closed";
                # Set the little led lights
                # piface.digital_write(0, 0)
                # piface.digital_write(1, 1)
            piface.digital_write_pullup(0, 0)
            # logger.debug("Debug message")
            # logger.info("Info message")
            # logger.warn("Warning message")
            # logger.error("Error message")
            # logger.info("Info message")
            # logger.info ('Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
            time.sleep(10)
            ## Increment the door open counter so we can be reminded once. 
            if doorState is "open":
                doorOpenCtr = doorOpenCtr + 1
Пример #12
0
  def __init__(self):
    try:
      import pifacecommon
      import pifacedigitalio
      pifacedigitalio.init()
      #pifacecommon.core.init()

      self.on_pi=True
    except Exception as ex:
      logging.exception("Something awful happened!")
      self.on_pi=False

    if self.on_pi:
      self.pifacecommon = pifacecommon
      self.pifacedigitalio = pifacedigitalio

      self.pifacedigital = pifacedigitalio.PiFaceDigital()
      self.listener = pifacedigitalio.InputEventListener(chip=self.pifacedigital)
Пример #13
0
    def __init__(self, input_pins = [0,1,2,3,4,5,6,7], output_pins = [0,1,2,3,4,5,6,7]):
        logger.debug("__init__(input_pins = %s, output_pins = %s)", input_pins, output_pins)
        self.__InputPins = map(int, input_pins)
        self.__OutputPins = map(int, output_pins)

        doorpi.DoorPi().event_handler.register_event('OnKeyPressed', __name__)

        p.init()

        self.__listener = p.InputEventListener()
        for input_pin in self.__InputPins:
            self.__listener.register(input_pin, p.IODIR_ON, self.event_detect)
            doorpi.DoorPi().event_handler.register_event('OnKeyPressed_'+str(input_pin), __name__)
        self.__listener.activate()

        # use set_output to register status @ dict self.__OutputStatus
        for output_pin in self.__OutputPins:
            self.set_output(output_pin, 0, False)
Пример #14
0
def setup(hass, config):
    """Set up the Raspberry PI PFIO component."""
    import pifacedigitalio as PFIO

    pifacedigital = PFIO.PiFaceDigital()
    hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital)

    def cleanup_pfio(event):
        """Stuff to do before stopping."""
        PFIO.deinit()

    def prepare_pfio(event):
        """Stuff to do when home assistant starts."""
        hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_pfio)

    hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_pfio)
    PFIO.init()

    return True
Пример #15
0
def main():
    piface.init()
    parser = OptionParser()

    usage = "cmd -s <a1>"

    parser.add_option("-s", "--selection", type ="string", help="-s <b3,b5,d3,d5,c3,c5", dest ="selection")

    options,arguments = parser.parse_args()

    if(options.selection not in valid_selections):
        print "Invalid Selection"
    else:
        idle_state();
        if options.selection == "b3":
            snd_b();
            idle_state();
            snd_three();
        elif options.selection == "b5":
            snd_b();
            idle_state();
            snd_five();
        elif options.selection == "d3":
            snd_d();
            idle_state();
            snd_three();
        elif options.selection == "d5":
            snd_d();
            idle_state();
            snd_five();
        elif options.selection == "c3":
            snd_c();
            idle_state();
            snd_three();
        elif options.selection == "c5":
            snd_c();
            idle_state();
            snd_five();
        idle_state();
Пример #16
0
def main(*args):
    power = int()
    ## Cycle de démarrage de PC
    try:
        with open('state.txt','r') as state:
            power = int(state.read())
    except:
        print 'ERREUR STATE READ'
        
    if power == 0:
        pifacedigitalio.init()
        pifacedigitalio.digital_write(1,1)
        time.sleep(0.3)
        pifacedigitalio.digital_write(0,1)
        time.sleep(0.2)
        pifacedigitalio.digital_write(1,0)
        with open ('state.txt','w') as state:
            state.write('1')
    if power == 1:
        pifacedigitalio.init()
        with open ('state.txt','w') as state:
            state.write('0')       
Пример #17
0
def init(init_board=True):
    try:
        pifacedigitalio.init(init_board)
        pfd = True
    except pifacecommon.core.InitError as e:
        print("Error initialising PiFace Digital: ", e)
        print("Running without PiFace Digital.")
        pfd = False
    except pifacedigitalio.NoPiFaceDigitalDetectedError:
        print("No PiFace Digital detected, running without PiFace Digital.")
        pfd = False

    global proc_comms_q_to_em
    global proc_comms_q_from_em
    proc_comms_q_to_em = Queue()
    proc_comms_q_from_em = Queue()

    # start the gui in another process
    global emulator
    emulator = Process(
        target=run_emulator,
        args=(sys.argv, pfd, proc_comms_q_to_em, proc_comms_q_from_em))
    emulator.start()
Пример #18
0
    def play(self):
        working = True
        p.init()

        while working:
            S1 = p.digital_read(0)
            S2 = p.digital_read(3)

            if S1 == 1:
                # Send -1 to move player to the left
                msg = '-1'
                self.sock.sendto(msg, (self.UDP_IP, self.UDP_PORT))

                # Turn on the LED while the button is pressed
                p.digital_write(0, 1)

                # Wait until the button is let go before reading a new bit
                while p.digital_read(0) == 1:
                    pass

                # Turn off the LED
                p.digital_write(0, 0)

            if S2 == 1:
                # Send 1 to move player to the right
                msg = '1'
                self.sock.sendto(msg, (self.UDP_IP, self.UDP_PORT))

                # Turn on the LED while the button is pressed
                p.digital_write(3, 1)

                # Wait until the button is let go before reading a new bit
                while p.digital_read(3) == 1:
                    pass

                # Turn off the LED
                p.digital_write(3, 0)
Пример #19
0
def main():
	from time import sleep
	import pifacedigitalio as p
	p.init()
	speed = 1

	while(True):
		if p.digital_read(0):
			speed = 0.7
		elif p.digital_read(1):
			speed = 0.5
		elif p.digital_read(2):
			speed = 0.4
		elif p.digital_read(3):
			speed = 0.2
		elif p.digital_read(4):
			speed = 0.05
		
		print("Speed:" + str(speed))
		
		p.digital_write(0,1) #turn 0 on (green)
		p.digital_write(3,1) #turn 3 on (buzzer)
		sleep(speed)
		p.digital_write(3,0) #turn 3 off (buzzer)
		p.digital_write(0,0) #turn 0 off (green)
		p.digital_write(1,1) #turn 1 on (yellow)
		p.digital_write(3,1) #turn 3 on (buzzer)
		sleep(speed)
		p.digital_write(3,0) #turn 3 off (buzzer)
		p.digital_write(1,0) #turn 1 off (yellow)
		p.digital_write(2,1) #turn 2 on (red)
		p.digital_write(3,1) #turn 3 on (buzzer)
		sleep(speed)
		p.digital_write(3,0) #turn 3 off (buzzer)
		p.digital_write(2,0) #turn 2 off (red)
	
	return 0
Пример #20
0
 def setUp(self):
     self.old_read_bit = pifacecommon.core.read_bit
     pifacedigitalio.init()
     # function is supposed to return 1, testing with 0
     pifacecommon.core.read_bit = lambda pin, port, board: 0
Пример #21
0
 def setUp(self):
     pifacedigitalio.init()
Пример #22
0
import pifacedigitalio as p
from time import sleep
import os

fh = open("/tmp/pwm0.duty", "w")
fh.write("100")
fh.close
p.init()
duty=100.0
teller=0
while True:
	p.digital_write(6,1) #uit
	sleep((1.0-duty/100.0)/50)
	p.digital_write(6,0) #aan
	sleep((duty/100.0)/50)
	if teller > 100:
		duty_old=duty
		try:
  			with open("/tmp/pwm0.duty", "r") as fh:
		   		duty=int(fh.readline())
#				print("duty=%d"%duty)
				fh.close
				teller=0
		except:
  			print("oops")
  		if duty_old == duty:
  			while duty == 15:
  				try:
  					with open("/tmp/pwm0.duty", "r") as fh:
		   				duty=int(fh.readline())
#						print("duty=%d"%duty)
Пример #23
0
# set a format which is simpler for console use
formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)

logging.info('Starting')

if not pygame.mixer: logging.warning('Warning, sound disabled')

ser = None
  
pfd = None
try:
    pif.init()
    pfd = pif.PiFaceDigital()
except pif.NoPiFaceDigitalDetectedError:
    logging.warning('No PiFace card detected')
    pass

soundPath = 'christmassounds'
bgPath = os.path.join(soundPath, 'bg')
soundFXdict = {}
client = udp_client
last_fx_chn = None
last_fx_snd = None
bg_volume = 0.5
bg_files = []
bg_playing = 0
last_input_values = [0] * 8
def server(argv):
    global logger
    global running

    pfio.init()
    global pfd
    pfd = pfio.PiFaceDigital()

    global listener
    listener = pfio.InputEventListener(chip=pfd)
    for pin in range(8):
        listener.register(pin, pfio.IODIR_BOTH, input_handle)
    listener.activate()

    global inputs_com
    global listener_sockets

    if len(argv) > 1:
        if argv[1] == "inputs":
            inputs = list(map(int, sys.argv[2:]))
            for pin in inputs:
                inputs_com[pin].append(None)
        elif argv[1] == "stop":
            running = False
            listener.deactivate()
            sys.exit()
        else:
            received = exec_command(argv)
            print(received)
            logger.info(received)

    tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    tcpsock.bind(("", 1114))
    tcpsock.listen(10)

    while running:

        logger.info("waiting connection...")

        (clientsocket, (ip, port)) = tcpsock.accept()
        logger.info("Connection from %s %s" % (
            ip,
            port,
        ))

        r = clientsocket.recv(2048).decode('UTF-8')
        logger.info("receive: " + r)
        argv = r.split()

        if argv[1] == "stop":
            listener.deactivate()
            for dest in listener_sockets:
                if dest is not None:
                    dest.send(bytes("stop", 'UTF-8'))
                    logger.info("listener " + dest.recv(2048).decode('UTF-8'))
            running = False
            ret = "stopped"
        elif argv[1] == "inputs":
            inputs = list(map(int, argv[2:]))
            for pin in inputs:
                logger.info("add listener on pin: " + str(pin))
                inputs_com[pin].append(clientsocket)
            listener_sockets.append(clientsocket)
            ret = ""
        else:
            ret = exec_command(argv)
        clientsocket.send(bytes(ret, 'UTF-8'))
    tcpsock.close()
    logger.info("done")
Пример #25
0
# Pulses a motor (attached to the relays as H-bridge) in alternating directions
# N.C. on each relay are connected to one power rail, N.O. on each relay are connected to other power rail.

from time import sleep
import pifacedigitalio as pfdio
import signal
import sys

def signal_handler(signal, frame):
        pfd.output_pins[0].turn_off()
        pfd.output_pins[1].turn_off()
        sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

pfdio.init()

pfd = pfdio.PiFaceDigital()

l = 0
r = 1

while True:
	l = r
	r = 1 - l
	pfd.output_pins[l].turn_on()
	pfd.output_pins[r].turn_off()
	sleep(0.1)
	pfd.output_pins[l].turn_off()
	sleep(0.2)
Пример #26
0
#!/usr/bin/python3
#
# flash the output LEDs one by one
#

from time import sleep
import pifacedigitalio as pfio

pfio.init()
try:
	while (True):
		for loop in range(0,7):
			print("flashing %d" % loop)
			pfio.digital_write(loop,1)
			sleep(1)
			pfio.digital_write(loop,0)
			sleep(1)

except KeyboardInterrupt:
	print("Cleaning up")
	for loop in range(0, 7):
		pfio.digital_write(loop, 0)

pfio.deinit()
Пример #27
0
def toggle_door_pi_face(door):
    pi_face.init()
    pi_face.digital_write(door, 1)
    sleep(1)
    pi_face.digital_write(door, 0)
Пример #28
0
	def __init__(self):
		pifacedigitalio.init();
		self.board = pifacedigitalio.PiFaceDigital();
		self.lights = Lights(self.board);
		self.move = Move(self.board);
Пример #29
0
#               7) All LEDs should be off
#               8) All LEDs on ALL PiFace boards are switched on together for 5 sec and then switched off
#               9) All LEDs should be off
#
# History:      Original release.
#
# Copyright:    2013 (c) Premier Farnell Limited
#
# License:      GPLv3+
#
#==============================================================

import pifacedigitalio as pfio;
from time import sleep;

pfio.init(True,0,0);    # Assumes the PiRack SPI CE jumpers are in the unswapped position.
                        # If the PiRack SPI CE jumpers are in the swapped position use:
                        # pfio.init(True,0,1);

#==============================================================
# Declaration of Constants

CLEDOFF = 0;            # Switch LED off
CLEDON = 1;             # Switch LED on

CBOARD1 = 0;            # PiFace board 0
CBOARD2 = 1;            # PiFace board 1
CBOARD3 = 2;            # PiFace board 2
CBOARD4 = 3;            # PiFace board 3

CLED1 = 0;              # LED 0
Пример #30
0
out.write(str(pid))
out.close()


pfd = p.PiFaceDigital(0)

#these have negative logic so invert the output
pfd.output_pins[2].turn_on()
pfd.output_pins[3].turn_on()
pfd.output_pins[4].turn_on()
pfd.output_pins[5].turn_on()


#register all inputs for interrupt routines

p.init(False)	#do not let the init function reset the board
l = p.InputEventListener(pfd)
#each bit must be registered with either on or off states to generate interrupt
l.register(0, p.IODIR_OFF, send_data_off)
l.register(0, p.IODIR_ON, send_data_on)
l.register(1, p.IODIR_OFF, send_data_off)
l.register(1, p.IODIR_ON, send_data_on)
l.register(2, p.IODIR_OFF, send_data_off)
l.register(2, p.IODIR_ON, send_data_on)
l.register(3, p.IODIR_OFF, send_data_off)
l.register(3, p.IODIR_ON, send_data_on)
l.register(4, p.IODIR_OFF, send_data_off)
l.register(4, p.IODIR_ON, send_data_on)
l.register(5, p.IODIR_OFF, send_data_off)
l.register(5, p.IODIR_ON, send_data_on)
l.register(6, p.IODIR_OFF, send_data_off)
Пример #31
0
'''
This program is used to signal the RPi connected to the Arduino to open the gate once the button
is pressed by the user
'''
import pifacedigitalio as pfio
import socket
from time import sleep
from sys import argv

# get the port and host address of the RPi connected to the servo motor
port = sys.argv[1]
host = sys.argv[2]

button = 0

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = (host, port)

pfio.init()
while (1):
    # If the button is pressed, open the gate
    if pfio.digital_read(button):
        print("here")
        sleep(1)
        s.sendto(("O").encode('utf-8'), server_address)

s.shutdown(1)
Пример #32
0
#   PYTHONPATH=`pwd` python dooraction.py start
import sqlite3
import logging
import time
import os
from daemon import runner
import pycurl
import pifacedigitalio as piface

conn = sqlite3.connect('/var/sqlite/garagemon.db')

c = conn.cursor()
c.execute('SELECT command FROM dooraction WHERE completion_time is NULL')
command = c.fetchone()
#print command

c.execute('SELECT current_position FROM position')
status = c.fetchone()
#print status

if status != command:
	piface.init()
	piface.digital_write(0,1)
	time.sleep(1)
	piface.digital_write(0,0)
	## Set db completion_time




Пример #33
0
from time import sleep
import pifacedigitalio as p
p.init()

while(True):
  print("waiting")
  if(p.digital_read(2)):
    print("Switch 2 was pressed")
Пример #34
0
from time import sleep
import pifacedigitalio


DELAY = 1.0  # seconds


if __name__ == "__main__":
    pifacedigitalio.init()
    pifacedigital = pifacedigitalio.PiFaceDigital()
    while True:
        pifacedigital.leds[7].toggle()
        sleep(DELAY)
Пример #35
0
# test feeder control with python script

import pifacedigitalio as pf
from time import sleep

if __name__ == '__main__':
    pf.init()

    # set forward direction
    pf.digital_write(1, 0)
    sleep(1)
    # turn on motor
    print('Running motor forward...')
    pf.digital_write(0, 1)
    sleep(5)
    print('Changing Direction..')
    # turn off motor
    pf.digital_write(0, 0)
    sleep(1)
    # set reverse direction
    pf.digital_write(1, 1)
    sleep(1)
    # turn on motor
    print('Running motor reversed...')
    pf.digital_write(0, 1)
    sleep(5)
    # turn off motor
    pf.digital_write(0, 0)
    print('Done!')
#!/usr/bin/python
# A pound sign (hash) # is used as a comment so that Python ignores it
# The top line tells the computer what language we are using #!/usr/bin/python

#####YOU NEED TO EDIT THIS VALUE###############################################
height = 0.72  # height in metres of the electromagnet above the tin foil switch

#######YOU DON'T NEED TO EDIT ANYTHING BELOW HERE (but you can, it's fun!)#####
############################IGNORE THESE BITS##################################
##### We tell it what external libraries we will be using.
# In our case, we are using the PiFace###########
import pifacecommon       # Read the pifacecommon library
import pifacedigitalio    # Read the pifacedigitalio library
pifacedigitalio.init()    # Initialise the PiFace making it ready for use
pifacedigital = pifacedigitalio.PiFaceDigital() 
                          # PiFace now accessed from the pifacedigital variable
################################################ End of PiFace additions
# We are going to need to use the time library
import time
#################################################End of imported libraries#####

# Check tinfoil switch is not already pressed and exit if it is
if ( pifacedigital.input_pins[0].value == 1 ):
    print ("Warning. Tin Foil switch is pressed")
    print ("Exiting.")
    exit()
################################################################

####################COIL ENERGISING#############################
input = "n" # We don't want the countdown to start just yet
                    # so we set a variable start_the_program to n