Compiling and running code on the Web IDE

I am so lost in what I am supposed to do in order to get the code onto my particle. This is my code:

    Servo myServo;
    int servoPin = A5;
    int servoPos = 0;

    void setup()
    {
      myServo.attach(A5);
      Particle.function("servo", servoControl); //register Particle
      Particle.variable("servoPos", &servoPos, INT); //keep cloud variable for current position
    }

    void loop()
    {
    }

    int servoControl(String command)
    {
      //Convert
      int newPos = command.toInt(); //Make sure it is in right range
      servoPos = constrain(newPos, 0, 180); //set position

      myServo.write(servoPos); //Set the Servo

      return 1; //done
    }

From what I have read, I need to somehow register my function but I’m not quite sure how? And what are the steps for after that in order to get everything to work?

You need to hit the Flash :zap: button on the top left area.

Before that, make sure you Star :star: the device you are targeting under the Devices tab.

As for Particle.function() registration, if you define it in the setup() it will be registered for you so don’t worry about that.

Here’s a guide for you to follow: https://docs.particle.io/guide/getting-started/build/photon/#flashing-your-first-app

What does starring the device do just wondering?

You might have 10 devices so you need to select the specific one that you want to flash your user code to. :wink:

Do I need to type anything into the CLI or should flashing it just work assuming I have my wiring correct?

CLI? You are using the the Web IDE, right? If you are using the Web IDE, there is no need to do anything with the CLI.

Once you flash, look at the centre bottom black console box that would tell you Flash success if everything worked well.