My servo motor isnt moving when ir sensor senses something

I am trying to get the servo motor to turn 180 degrees and then back to 0 degrees when the IR sensor senses something Circuit. techleader

import time
from pyfirmata import Arduino, util

board = Arduino('COM5')

iterator = util.Iterator(board)
iterator.start()

motor = board.get_pin('d:6:s')

sensorPinNo = 2

sensorPin = board.get_pin('d:' + str(sensorPinNo) + ':i')

print("Nothing is being sensed ")

rlt = sensorPin.read()
while True:
    if rlt:
        print("Sensor has detected something")

        def setServoAngle(angle):
            print("Wiping In Progress")
            for i in range(0, 180):
                setServoAngle(i)
                motor.write(angle)
            for i in range(180, 1, -1):
                setServoAngle(i)
                motor.write(angle)

        print("Program Exit")
        board.exit()

I have: Arduino uno, servo motor, IR sensor, Buzzer, LED, Resistors, Breadboard, Jumper wires

Are you going to post the Arduino code ?

…all of it ..