I want to build simple fuzzy logical with two inputs: speed and distance. So, I have ultrasonic sensor and servo motor. Robot should move faster toward hand if I move hand fast away from sensor (increasing distance very fast), or move fast away if I move hand fast toward sensor. Something like this:
if distance is FAR and speed is HIGH - move toward FAST if distance is FAR and speed is LOW - move toward SLOW if distance is NEAR and speed is HIGH - move away FAST if distance is NEAR and speed is LOW - move away SLOW if distance is SAFE and speed is LOW - do nothing if distance is SAFE and speed is high - do nothing // (safe zone is range eg. 10-15 cm or something).
For result robot should avoid contact with hand but he will always follow hand (robot must be in safe zone - eg. 10-15 cm away from hand).
I have this code eFLL/arduino_simple_sample.ino at master · zerokol/eFLL · GitHub
but there is only one input and two outputs, and I am beginner with arduino so I need little help
I have standard HC-SR04 sensor and SG90 servo, Arduino UNO.