Beispiel #1
0
	def __init__(self):
		Pi_rev = wiringpi2.piBoardRev()	#@TODO: use this?
		self.GPIOS = {
			'internal_buzzer': 11,
			'latch': 7,
			'unlock_LED': 15,
			'deny_LED': 13,
			'buzzer': 12, 
			'doorStatus1': 19,
			'doorStatus2': 21,
		}
		
		#set up I/O pins
		wiringpi2.wiringPiSetupPhys()
		wiringpi2.pinMode(self.GPIOS['unlock_LED'], 1)
		wiringpi2.pinMode(self.GPIOS['deny_LED'], 1)
		wiringpi2.pinMode(self.GPIOS['latch'], 1)
		wiringpi2.pinMode(self.GPIOS['internal_buzzer'], 1)
		wiringpi2.pinMode(self.GPIOS['doorStatus1'], 0)
		wiringpi2.pinMode(self.GPIOS['doorStatus2'], 0)
		
		GPIO.setup(9, GPIO.IN)  
		GPIO.setup(10, GPIO.IN)  
		#GPIO.add_event_detect(9, GPIO.FALLING, callback=self.arm_security, bouncetime=300)
		#Set up Hardware PWM - Only works on GPIO 18 (Phys 12)
		wiringpi2.pwmSetMode(0)				# set PWM to markspace mode
		wiringpi2.pinMode(self.GPIOS['buzzer'], 2)      # set pin to PWM mode
		wiringpi2.pwmSetClock(750)   			# set HW PWM clock division (frequency)
		wiringpi2.pwmWrite(self.GPIOS['buzzer'], 0)
		
		proc = subprocess.Popen(['nfc-list'], stderr=subprocess.PIPE)
		result = proc.stderr.read()
		self.PN532 = False if 'Timeout' in result else True
		if not self.PN532:
			self.nfc = NFC.MFRC522()
 def execute(self):
     # pin 1 -> green LED
     # pin 2 -> red LED
     # init mode
     try:
         wiringpi2.piBoardRev()
         wiringpi2.wiringPiSetup()
         wiringpi2.pinMode(self.pin, 1)
         # turn on gpioval
         print "Turn On Pin", self.pin
         wiringpi2.digitalWrite(self.pin, 1)
         sleep(1)
     finally:
         # turn off gpioval
         print "Turn Off Pin", self.pin
         wiringpi2.digitalWrite(self.pin, 0)
Beispiel #3
0
#!/usr/bin/python
import time
import wiringpi2 as wiringpi
import RPi.GPIO as GPIO
import subprocess
from server import sun
import rat
import time

time.sleep(10)


GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Pi_rev = wiringpi.piBoardRev()
wiringpi.wiringPiSetupGpio() 
wiringpi.pinMode(18,2)

rat.post_log("Light Control Started")

last_status = None

while True:
    settings = rat.get_settings()
    # only turn LEDs on if its getting dark, and recording enabled
    if settings:
        if sun.is_it_dark() and GPIO.input(24)==0 and int(settings['disable_recording'])==0:
            ir_led = float(settings['ir_led'])/100.0
            if last_status!='night':
                rat.post_log("It's night. Set LEDs to: {0}%".format(ir_led))
                last_status = 'night'
            wiringpi.pwmWrite(18, int(1024*ir_led))
Beispiel #4
0
def test1():
	print "#######################"
	print "Pi Board Revision: ", p.piBoardRev()
	print "#######################"
	return 0
Beispiel #5
0
#!/usr/bin/env python
import wiringpi2
print wiringpi2.piBoardRev()