示例#1
0
def main():
    try:
        led = 7
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(led, GPIO.OUT)
        print "Light on"
        GPIO.output(led, GPIO.HIGH)
        time.sleep(1)
        print "Light off"
        GPIO.output(led, GPIO.LOW)
    except Exception, e:
        print e
示例#2
0
def main():
    try:
        led = 7
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(led, GPIO.OUT)
        print "Light on"
        GPIO.output(led, GPIO.HIGH)
        time.sleep(1)
        print "Light off"
        GPIO.output(led, GPIO.LOW)
    except Exception, e:
        print e
示例#3
0
    def MFRC522_Init(self):
        GPIO.output(self.NRSTPD, 1)

        self.MFRC522_Reset()

        self.Write_MFRC522(self.TModeReg, 0x8D)
        self.Write_MFRC522(self.TPrescalerReg, 0x3E)
        self.Write_MFRC522(self.TReloadRegL, 30)
        self.Write_MFRC522(self.TReloadRegH, 0)

        self.Write_MFRC522(self.TxAutoReg, 0x40)
        self.Write_MFRC522(self.ModeReg, 0x3D)
        self.AntennaOn()
示例#4
0
def main():
    argc = len(sys.argv)
    if argc != 2:
        print "usage:%s pin" % sys.argv[0]
        return
    pin = int(sys.argv[1])
    try:
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(pin, GPIO.OUT)
        print "Set pin%d HIGH" % pin
        GPIO.output(pin, GPIO.HIGH)
        time.sleep(1)
        print "Set pin%d LOW" % pin
        GPIO.output(pin, GPIO.LOW)
    except Exception, e:
        print e
def main():
    argc = len(sys.argv)
    if argc != 2:
        print "usage:%s pin" % sys.argv[0]
        return
    pin = int(sys.argv[1])
    try:
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(pin, GPIO.OUT)
        print "Set pin%d HIGH" % pin
        GPIO.output(pin, GPIO.HIGH)
        time.sleep(1)
        print "Set pin%d LOW" % pin
        GPIO.output(pin, GPIO.LOW)
    except Exception, e:
        print e
示例#6
0
 def __init__(self, dev='/dev/spidev0.0', spd=1000000):
     spi.openSPI(device=dev, speed=spd)
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(22, GPIO.OUT)
     GPIO.output(self.NRSTPD, 1)
     self.MFRC522_Init()