The present invention relates to a biocompatible device that integrates electromagnetic and mechanical elements and allows the combination of different mechanisms for voluntary closing of the intestinal lumen. The device can be used either with a stoma to control intestinal transit to the outside and avoid the use of collection pouches, or without a stoma to regulate intestinal transit for another medically necessary reason.