Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- from time import sleep
- from espeak import espeak
- import random
- import RPi.GPIO as GPIO
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(23, GPIO.IN) #First Sensor Pin
- GPIO.setup(24, GPIO.IN) #Second Sensor Pin
- visitor_count = 0
- counter = 0
- in_first = False
- out_first = False
- limit = 10
- responses = [ 'you are visitor number []',
- 'welcome, visitor []',
- 'hi, visitor number[]',
- 'take a look around, visitor number []']
- goodbye = [ 'goodbye',
- 'see you later']
- def reset() :
- global counter
- global in_first
- global out_first
- counter = 0
- in_first = False
- out_first = False
- #espeak.set_voice("mb-us1")
- #espeak.set_parameter(espeak.Parameter.Rate, 200)
- while True:
- if GPIO.input(23) and GPIO.input(24):
- reset()
- continue
- if debug:
- print "23: " + str(GPIO.input(23)) + ", 24: " + str(GPIO.input(24)) + " C: " + str(counter)
- if GPIO.input(23) and not(in_first):
- out_first = True
- if GPIO.input(24) and not(out_first):
- in_first = True
- if out_first or in_first :
- counter = counter + 1
- sleep(0.1)
- if out_first and GPIO.input(24) and (counter > 0) :
- visitor_count = visitor_count + 1
- speak = random.choice(responses) # Get a random response to speak back to the user
- espeak.synth(speak.replace("[]", str(visitor_count))) # Speak back to the user!
- os.system('clear')
- print str(visitor_count)
- reset()
- if in_first and GPIO.input(23) and (counter > 0) :
- speak = random.choice(goodbye) # Get a random response to speak back to the user
- espeak.synth(speak) # Speak back to the user!
- reset()
- if counter > limit :
- reset()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement