The rotating door lock DC motor can only rotate 90 degrees. You might find it worthwhile to mark the extremes of the rotation with a silver sharpie so you know where it stops. It takes approximately 5.5 seconds for the lock to rotate from either the lock to unlocked position or unlock to locked position.
To do some basic testing of the door lock you can connect the battery pack directly to the door lock and just reverse the jumper wires to make it rotate back and forth. When it stops moving that's all the farther it will go and you'll want to shut off the battery pack so you don't burn out the lock motor.
StopLock()
Lock(t)
UnLock(t)
vcgencmd measure_temp
source ~/.profile
workon cv
pip install RPi.GPIO
python -m idlelib
vcgencmd measure_temp
scaleFactor
and minNeighbors
.scaleFactor
and minNeighbors
to the numbers you found in the program above.if not isinstance(faces, tuple):
When a cat face is detect the faces
object becomes a numpy array. In simple terms a coordinate map of a rectangle (x position, y position, width and height). It turns out that when the faces object is empty it's just a tuple. We can use the isinstance()
function to identify when a cat face is detected.break
statement so the program will terminate after the first UnLock()
call.lockPosition
.lockPosition = "unlocked"
because the lock mechanism has to be unlocked for you to actually close the box. if
" statements. if lockPosition == "unlocked"
is used so that when you press the button the door will lock if lockPosition is equal to unlocked but do nothing if it isn't. We could press on the button all day and won't have to worry about destroying the lock motor!if lockPosition == "locked"
is used so that if the camera sees a cat's face and the door is already unlocked, the program won't try to keep unlocking it.