I intend to simulate a coffee dispenser with a maximum capacity of 9 capsules.
The act of placing or removing capsules are controlled by the 5th and 6th buttons (SW5 and SW6).
When the maximum capacity is reached, the VE valve (D8) is activated, that blocks the entrance of more capsules, and it will only open again when the tank's capacity is below 30% of the maximum value intended.
The maximum capacity can be either 4, 6, or 9 capsules.
The selection of the maximum capsule quantity is made by activating the respective switch (SW4, SW6, SW9).
There's also a display (the further right one) which indicates the number of existing capsules in the deposit.
To determine the 4th, 6th, and 9th switches values, there must be done, for each switch, two readings that have a delay of 1.5 ms relatively to each other and both must have the same logic value so there is a valid reading.
Can anyone help me with this project, or provide information on how to solve this?