nfc raspberrypi felica servo: turn on / off light of a room

nfc raspberrypi felica servo: turn on/off light of a room

Turn the servo only for your suica.

turn_servo.py


import nfc
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
servo_pin = 3
GPIO.setup(servo_pin, GPIO.OUT)
servo = GPIO.PWM(servo_pin, 50)
my_id = '01010501b00ac30b'

def connected (tag):
    return
    #time.sleep(1)
    
clf = nfc.ContactlessFrontend('usb')
servo.start(0)
status = 'opened'

while True:
    print('waiting...')
    tag = clf.connect(rdwr={'on-connect':connected})
    felica_id = str(tag.idm).encode("hex")
    if (my_id == felica_id):
        print('matched!!')
        #servo.start(0)
        if (status == 'opened'):
            #open the door
            servo.ChangeDutyCycle(2.0)
            status = 'closed'
        elif(status == 'closed'):
            #close the door
            servo.ChangeDutyCycle(5.0)
            status = 'opened'
        #servo.stop()
    else:
        print('invalid id!!')

    print(status)
    print('scaned')
    time.sleep(0.2)

servo.stop()
GPIO.cleanup()

Turn on / off the electricity in the room with the servo. I really wanted to open and close the door key, but I gave up because the key was unexpectedly hard. Moreover, Gamte implementation. Well.

IMG_3579.jpg

IMG_3578.jpg

https://youtu.be/x625sLmCasE

Supplement

Really http://kousaku-kousaku.blogspot.jp/2008/06/arduino.html http://qiita.com/kedtn/items/7174f5112d99f12ce0e7 http://kondo-robot.com/product-category/servomotor/krs http://radenzaiku.blog.shinobi.jp/%E3%83%AD%E3%83%9C%E3%83%83%E3%83%88%E5%85%A8%E8%88%AC/futaba%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%B5%E3%83%BC%E3%83%9C%E3%81%AE%E8%A7%92%E5%BA%A6%E5%8F%96%E5%BE%97 I thought about taking the angle of the servo and improving the accuracy like this, but it became troublesome someday. With the KRS servo, you can also get the angle ...

Recommended Posts

nfc raspberrypi felica servo: turn on / off light of a room
Easy installation of OpenCV on RaspberryPi 3+
Turn off Python 2.7 on Debian Stretch
Turn the E-MAX mini servo ES08A II with hardware PWM on RaspberryPi