File Exchange

image thumbnail

Auto flush

version (702 KB) by Techsource Technical Team
Demonstrates auto flushing using an ultrasonic sensor.


Updated 06 Jul 2015

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

I went into one of the toilets in a mall. Saw the auto flushing and couldn't stop thinking about it. So here it is.
This model illustrates auto flushing in the men’s toilet (or women's). When it detects human presence, it will flush once before peeing begins. When the process is completed, it will flush again. Flushing is represented by a rotating DC motor.

Cite As

Techsource Technical Team (2021). Auto flush (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

omar Elkawokgy

mahmoud bakr

I got Index exceeds array bounds error
any solution?

I did not work with s-functions at all , where to start (any recommended readings,videos,course)?

Francisco Villarreal

I get error: 'sonar' undeclared (first use in this function)
int uS = sonar.ping_median();

What am I doing wrong?

Hi Ihab, yes it is possible to run the S-Function on the Arduino UNO.

Ihab Al Khaldi

can i run this s function on arduino uno?

Ihab Al Khaldi

Do i need to specify data in the model explorer for the chart?

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!