Servo not working in arduino

Okay. I finally figured it out. The issue was I had not connected the ground of the arduino to the ground of my power supply. It works fine now.