If you have trouble running your code in the simulator, it could be for one of the following reasons:

1. The simulator is not opened, i.e the Play  button not pressed.
2. There is an incompatibility between the ports specified in your code and the ports used by your simulated robot. Follow the steps below to fix the issue:

 Select the robot in the simulator

 Open Object Properties

(a) Expand EV3 heading


(b) Pay attention to the ports on the digital brick used.
(c) Open the LEGO programming environment and check if what is specified in your motion and sensor blocks match the simulated robot's object properties.