if BGGetDI(2) == 1 then -- check if the proximity sensor sees a backage close -- if this is the case we can set a globabl varaible to 10 -- using the following command SetUserVal(uservar1,1); -- stop the conveyer belt BGSetDO(0,0) end if BGGetDI(2) == 0 then -- if the proximity sensor is 0 -- move the conveyer belt forward and update the global variable -- update it with small value maybe 1 SetUserVal(uservar1,0); BGSetDO(0,1) end