SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By hammer5858
#195474
I can send the "2" via pushing a button on my app to pulse for 500ms.

I would like to insert a text field instead of the button for pulse to type a 4 value that will be on the arduino. It would be 1234 in the text box (example) corresponding to 1234 for pulse on the arduino instead of just sending the "2" for pulse. if the user sends anything other than what is predetermined on the arduino such as 1234, nothing happens. So i would like to know how to input the text box and submit in place of the (new Uint8Array([2]) in this...

<button class="yellow wide" onclick="app.connect()">CONNECT</button>
<br>
<button class="green wide big" onclick="app.ledOff()">SWITCH ON</button>
<br>
<button class="red wide big" onclick="app.ledOn()">SWITCH OFF</button>
<br>
<button class="green wide big" onclick="app.ledPulse()">PULSE ON/OFF</button>


<script>
// Application object.
var app = {}

// Connected device.
app.device = null;

// Turn on LED.
app.ledOn = function()
{
app.device && app.device.writeDataArray(new Uint8Array([1]), '0000ffe1-0000-1000-8000-00805f9b34fb');
}

// Turn off LED.
app.ledOff = function()
{
app.device && app.device.writeDataArray(new Uint8Array([0]), '0000ffe1-0000-1000-8000-00805f9b34fb');
}

// Pulse LED.
app.ledPulse = function()
{
app.device && app.device.writeDataArray(new Uint8Array([2]), '0000ffe1-0000-1000-8000-00805f9b34fb');
}

Please help me. Please please please.