2 IR sensors with servos

Hi everyone! I'm a new user for my cocktail machine school project.
My question is how to write the code which use 2 IR sensors for detecting and responding.

If 1 IR sensor detect something, servo motor turn clockwise 90°.
If 2 IR sensor detect something, servo motor turn anti-clockwise 120°

Thank you!

The first thing to do is to sort out what you actually want to happen. Servos go to a specific position,they don't go so many degrees clockwise or anti-clockwise. And where should the servo be when neither IR sensor detects anything?

There are several examples in the IDE showing you how to use a servo. And there are others showing you how to read an IR sensor though there are several different types of those so you'll have to be more specific about exactly what sensors you have.

Steve

Anyone can help me to write the code? thank a lot!

Terencellh:
for my cocktail machine school project.

Terencellh:
Anyone can help me to write the code?

That would be cheating.

Split your project in two or more parts. Start with only ONE IR sensor.
Let the sketch print something to the serial monitor when the sensor is detecting something and print something else when the sensor is not detecting. You might want to Google "Arduino state machine" for that.
When you have successfully detected the states of the two IR sensors, then you could use if() statements to make the servos move.
Post your coding attempts and a diagram if you want help with that.
Leo..

Terencellh:
Anyone can help me to write the code? thank a lot!

Yes. Once you have made an attempt at writing the code and posted it here there are loads of us who can help you to get it working.

But if "help me write" means write the code for you without you putting any effort in, then probably not.

Steve