I'm controlling a set of 30 fans by sending an array of 30 on/off values to a chip (MM5450) which are triggered by people walking past the ultrasonic sensors. I would like to increase the strength as people get closer to it and slower decrease the power as they leave.
As I understand it the logic might be as follows:
If distance of left sensor is between 300 & 400 send ON every 10 cycles
If distance of left sensor is between 200 & 300 send ON every 5 cycles
If distance of left sensor is between 100 & 200 send ON every 3 cycles
If distance of left sensor is between 0 & 100 send ON every cycles
Could anyone point out what this would look like in programming language?
Can it be done is a less incremental/linear manner?