# Change a Variable w/ HTML

**URL:** <https://community.particle.io/t/change-a-variable-w-html/28269>\
**Category:** Getting Started\
**Created:** [January 2, 2017, 1:27am UTC](https://community.particle.io/t/change-a-variable-w-html/28269 "2017-01-02T01:27:47Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [January 2, 2017, 1:27am UTC](https://community.particle.io/t/change-a-variable-w-html/28269/1 "2017-01-02T01:27:47Z")

</div>

I have worked hard to minimize the bandwidth for an Electron Project that monitors pressure sensors and CT’s.  
My code uses #define(s) to establish publish delays for various sensors. The Electron is remotely deployed.  
I’d like to swap from using hard coded #define delays to a Particle Variable that I will change every few days remotely, verses a full OTA firmware flash any time I want to modify the publish delays.

I believe I’ve previously read a thread or tutorial on what I want to accomplish, but I can’t find it now.

Any advise or direction to take for the inexperienced ?  
Basically, I need to change an Electron variable from the Cloud (not very often), but avoid any unnecessary data usage.

---

<div class="post-metadata">

**Author:** ![harrisonhjones](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/harrisonhjones/32/4132_2.png) [@harrisonhjones](https://community.particle.io/u/harrisonhjones)\
**Post date:** [January 2, 2017, 2:51am UTC](https://community.particle.io/t/change-a-variable-w-html/28269/2 "2017-01-02T02:51:18Z")

</div>

Your question is a bit open-ended. Are you asking how one might technical issue an update to a Particle variable? If so, use a Particle.function. Are you asking how to setup a recurring job to update? If so, that really depends on what server platform (AWS, Azure, etc) and technologies you are using.

---

<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:** [January 2, 2017, 5:36pm UTC](https://community.particle.io/t/change-a-variable-w-html/28269/3 "2017-01-02T17:36:09Z")

</div>

I appoligize for my ignorance. Here’s another try:

My Electron code currently works with several defines above Setup() such as:

```
#define publish_delay_long 300000       
#define alarm_delay 3600000
int ThresholdCurrent = 30; 

blah blah.......   
void setup()

```

I would like to be able to use variables instead of the define statements and integers, But be able to remotely change these variables (w/ HTML,command line, etc) to fine-tune the electron’s publishing rate and subsequent data usage. The electron is 2 hours away from my office and it’s a fairly lengthy program for OTA flashing.

Should I use a Particle.Variable inside void loop(), or Particle.Function outside?  
Which method will “push” a new Integer to the electron, without the electron constantly checking ?

Thanks in advance for the Help.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 2, 2017, 5:46pm UTC](https://community.particle.io/t/change-a-variable-w-html/28269/4 "2017-01-02T17:46:43Z")

</div>

Hi @Rftop

You need a Particle function to set values--Particle variables are read-only. Here's a simple tutorial to help you along (note the syntax for Particle variables has been simplified since this was written, so check the doc):

> [@Tutorial: Spark Variable and Function on One Web Page](http://community.particle.io/t/tutorial-spark-variable-and-function-on-one-web-page/4181):
>
> Let’s say you have a Spark core with both a Spark variable and a Spark function. In my case, I have the world’s simplest servo control sketch, using the nice miniature servo in the Spark Maker Kit. Using these parts, we will build a servo that you can control from a web page anywhere and monitor the position of the servo too! Here’s a preview of the finished tutorial: [image] There is a coarse adjust slider, two fine adjust buttons, and the current position of the servo is displayed. That…

---

<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:** [January 2, 2017, 8:44pm UTC](https://community.particle.io/t/change-a-variable-w-html/28269/5 "2017-01-02T20:44:34Z")

</div>

Thanks @bko and @harrisonhjones !  
I really appreciate it 🕶
