In this project we will perform the control of a latch by means of an access key.
It consists of mounting a servo on the axis of a linear actuator that will act as latch pin, allowing the mobility of this.
The idea is that when entering the key, the servo change position depending on the state before it was found. It means that if it was open, it would close, and if it was closed, it would open
You will also need:
1 bluetooth usb
1 S9 mini servos
1 battery compartment.
In this case we will use the MIOIO App Inventor 2 development environment, since for this purpose it is more than enough.
Once the structure is assembled with the servo, proceed to connect the servo to the Shield MIOIOBot on the auxiliary pins as follows:
Now let's run the program that will control this servo.
The blocks in the part of the designer that we are going to need are:1 servo blocks MIOIOBOT.
- 12 buttons to enter the access code and to delete or accept the operation.
- 1 blocks tag that will show us the code that we are introducing.
- 1 block notification that will tell us if the code has been accepted.
Drag all those blocks into the designer with the following structure:
Now we go to the part of blocks and put the blocks according to the following figure:
In the blocks of the program we can see how there is a global variable that is the one that owns the key of access, we have put it here to facilitate the program and not to have to introduce it from the application. And another global variable "state" that will store the status of the servo either open, or closed.
The buttons 1 to 10 belong to the numeric keypad that we have created and their Click events only enter their value in the text box.
Button 11 is for deletion and its Clic event erases all the contents of the text field.
The button 12 is to accept the operation, and its Clic event compares the contents of the text field with the global variable of the password. If it is correct or incorrect, it will notify us with the event of the notifier. If it is correct, the servo will move depending on the state before it, which we know thanks to the global variable "state".