I don’t really know about your sensor, you can ask others but I think I will help you with the Servo Library.
The code is the following. Hope this help.
*If you don’t know // means to the arduino that do not read this.
The code I said if you plug in the value correctly, it will turn to three different trash can, one can for plastic, another for glass, and another for unidentified objects.
//include Servo Library
int servoPin = 13;
//set servoPin(13) as an output
int val = map (port, x, y, 0,1);
//This turn the value from the sensor (port) to the value (val) of 2 values, 1, and 0.
if (val==0); //if the value is 0
yourservo.write(180); //turn the servo to 180º
else if (val ==1); // if the value is 1
yourservo.write(180); //turn the servo to 0º
else //if not either of the two cases, or unidentified objects, throw into an unidentified trash bin.
yourservo.write(90); //turn the servo to 90º