# Report get website

**URL:** <https://community.particle.io/t/report-get-website/60931>\
**Category:** Developer Tools\
**Created:** [August 8, 2021, 9:42pm UTC](https://community.particle.io/t/report-get-website/60931 "2021-08-08T21:42:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![uthacod](https://avatars.discourse-cdn.com/v4/letter/u/839c29/32.png) [@uthacod](https://community.particle.io/u/uthacod)\
**Post date:** [August 8, 2021, 9:42pm UTC](https://community.particle.io/t/report-get-website/60931/1 "2021-08-08T21:42:47Z")

</div>

Good evening everyone.  
I’m trying to read the status of a led on a web page. It is programmed to turn on and off every 4 seconds. In particle console I get the values ​​"1" and “0” respectively. But I can’t collect this data on a web page.

```cpp
int ledPin = D7;
int statusPin;

void setup() {
    pinMode(ledPin,OUTPUT);
    Spark.variable("statusPin", &statusPin, INT);
}
void loop() {
  digitalWrite(ledPin,LOW);
  statusPin = digitalRead(ledPin);
  Particle.publish("Status", String(statusPin) , PRIVATE);
  delay(4000);
  digitalWrite(ledPin,HIGH);
  statusPin = digitalRead(ledPin);
  Particle.publish("Status", String(statusPin) , PRIVATE);
  delay(4000);

```

```auto
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael.2.1.0.min.js"></script>
<script src="justgage.1.0.1.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script>
var accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
var deviceID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var url = "https://api.spark.io/v1/devices/" + deviceID + "/statusPin";

function callback(status){
	if(status == "sucess"){
		if(statusPin == '0')
		alert("on");
		else{
		alert("off");	
		}
		g.refresh(statusPin);
		setTimeout(getReading,1000);
		}
}
function getReading(){
   	$.get(url, {access_token: accessToken}, callback);
}
</script>
</head>	
<body>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [August 9, 2021, 9:01am UTC](https://community.particle.io/t/report-get-website/60931/2 "2021-08-09T09:01:09Z")

</div>

This application note may help, [AN032 Calling the Particle API from a web page](https://docs.particle.io/datasheets/app-notes/an032-calling-api-from-web-page/).

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 9, 2021, 2:13pm UTC](https://community.particle.io/t/report-get-website/60931/3 "2021-08-09T14:13:52Z")

</div>

Just some notes about your code

- You should not use the `Spark` moniker anymore but rather `Particle`
- The three-parameter version of `Particle.variable()` is outdated and shouldn’t be used anymore
- Try to adopt a non-blocking coding paradigm as early as possible to prevent future headache - e.g. your `loop()` could look like this

```cpp
void loop() {
  static uint32_t msLastExec = 0;
  if (millis() - msLastExec < 4000) return; // bail out when nothing to do
  msLastExec = millis();
 
  statusPin = !statusPin; // toggle the value
  digitalWrite(ledPin, statusPin);
  Particle.publish("Status", String(statusPin));
}

```

---

<div class="post-metadata">

**Author:** ![uthacod](https://avatars.discourse-cdn.com/v4/letter/u/839c29/32.png) [@uthacod](https://community.particle.io/u/uthacod)\
**Post date:** [August 9, 2021, 5:41pm UTC](https://community.particle.io/t/report-get-website/60931/4 "2021-08-09T17:41:49Z")

</div>

> [@ScruffR](#):
>
> The three-parameter version of `Particle.variable()` is outdated and shouldn’t be used anymore

First thanks for the tip. I didn't understand the "The three-parameter version of Particle.variable() is out of date and should no longer be used" part. Where do I become aware of updates?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 9, 2021, 6:45pm UTC](https://community.particle.io/t/report-get-website/60931/5 "2021-08-09T18:45:35Z")

</div>

This would be the place  
[https://docs.particle.io/reference/device-os/firmware/#particle-variable-](https://docs.particle.io/reference/device-os/firmware/#particle-variable-)

Or you could use a faily new version to expose a calculated `Particle.variable()` (even using lambdas)

```cpp
Particle.variable("statusPin", []() -> bool { return digitalRead(ledPin); });

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/4/64635adccc35238caa19e9b553ec3e98b163d026.png) [@system](https://community.particle.io/u/system)\
**Post date:** [February 8, 2022, 6:45am UTC](https://community.particle.io/t/report-get-website/60931/6 "2022-02-08T06:45:43Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
