# How is a Particle.function called?

**URL:** <https://community.particle.io/t/how-is-a-particle-function-called/46510>\
**Category:** Cloud\
**Created:** [December 22, 2018, 10:58pm UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510 "2018-12-22T22:58:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tentoes](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tentoes/32/20045_2.png) [@Tentoes](https://community.particle.io/u/Tentoes)\
**Post date:** [December 22, 2018, 10:58pm UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/1 "2018-12-22T22:58:35Z")

</div>

I’m an experienced microcontroller programmer playing with an electron board.

Didn’t take long to get the led blinking and play with that for a while. The second example uses the particle.function call to get a message from somewhere, but I seem to have missed where this message comes from.

Following the example, I have

```auto
Particle.function("led",ledToggle);

```

and the function ledToggle

```auto
int ledToggle(String command) {
    /* Particle.functions always take a string as an argument and return an integer.
    Since we can pass a string, it means that we can give the program commands on how the function should be used.
    In this case, telling the function "on" will turn the LED on and telling it "off" will turn the LED off.
    Then, the function returns a value to us to let us know what happened.
    In this case, it will return 1 for the LEDs turning on, 0 for the LEDs turning off,
    and -1 if we received a totally bogus command that didn't do anything to the LEDs.
    */

    if (command=="on") {
        digitalWrite(led1,HIGH);
        return 1;
    }
    else if (command=="off") {
        digitalWrite(led1,LOW);
        return 0;
    }
    else {
        return -1;
    }
}

```

I’m guessing it takes messages like “led on” or “led off,” but what sends this message? Somewhere here on the site perhaps?

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [December 22, 2018, 11:16pm UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/2 "2018-12-22T23:16:38Z")

</div>

Have a look:

[https://docs.particle.io/tutorials/hardware-projects/hardware-examples/photon/#control-leds-over-the-39-net](https://docs.particle.io/tutorials/hardware-projects/hardware-examples/photon/#control-leds-over-the-39-net)

---

<div class="post-metadata">

**Author:** ![Tentoes](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tentoes/32/20045_2.png) [@Tentoes](https://community.particle.io/u/Tentoes)\
**Post date:** [December 23, 2018, 12:56am UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/3 "2018-12-23T00:56:08Z")

</div>

Oh, wow. Instructions!

Thanks. I knew I missed something.

---

<div class="post-metadata">

**Author:** ![Tentoes](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tentoes/32/20045_2.png) [@Tentoes](https://community.particle.io/u/Tentoes)\
**Post date:** [December 23, 2018, 1:48am UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/4 "2018-12-23T01:48:15Z")

</div>

Ok. I found my device id, but where do I find the access token?

Doesn’t seem to be ICCID or IMEI from the Particle Console.

---

<div class="post-metadata">

**Author:** ![Rftop](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rftop/32/16896_2.png) [@Rftop](https://community.particle.io/u/Rftop)\
**Post date:** [December 23, 2018, 2:34am UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/5 "2018-12-23T02:34:32Z")

</div>

> [@Tentoes](#):
>
> I’m guessing it takes messages like “led on” or “led off,” but what sends this message? Somewhere here on the site perhaps?

The Docs Moors7 linked to shows you how to toggle the led from your Particle Console.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/1/d/1d4c1f8e852e86f1b5051d9c8f808fa5c8a7e5f4.png)

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [December 23, 2018, 8:11am UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/6 "2018-12-23T08:11:33Z")

</div>

> [@Tentoes](#):
>
> but where do I find the access token?

Have a look 😉

[https://docs.particle.io/tutorials/developer-tools/build/photon/#account-information](https://docs.particle.io/tutorials/developer-tools/build/photon/#account-information)

---

<div class="post-metadata">

**Author:** ![Tentoes](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/tentoes/32/20045_2.png) [@Tentoes](https://community.particle.io/u/Tentoes)\
**Post date:** [December 23, 2018, 6:07pm UTC](https://community.particle.io/t/how-is-a-particle-function-called/46510/7 "2018-12-23T18:07:58Z")

</div>

And, for anybody googling…

You just click the gear icon in the bottom left of the Build screen.
