# Using a button to trigger an LED Question

**URL:** <https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437>\
**Category:** General\
**Created:** [2 November 2019 14:07 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437 "2019-11-02T14:07:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![spen0203](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@spen0203](https://discourse.nodered.org/u/spen0203)\
**Post date:** [2 November 2019 14:07 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/1 "2019-11-02T14:07:55Z")

</div>

Hey guys im learning node-red and made a flow that is supposed to allow me to click a button on pin 0 of my arduino and trigger a function that changes between 1 and 0 for an led on pin 11.

This flow works correctly when i use an inject but if i use arduino In on pin 0 it doesn't detect the press.

Flow im working on uses:  
Arduino in on pin0 -\> 500ms delay -\> function -\> arduino out pin 11

my function is:

```auto
var count = global.get('count') || 0;

if(count == 1){
    global.set('count',0)
}
if(count == 0)
{
    global.set('count',1)
}

// set the payload to the level and return
msg.payload = count;
return msg;

```

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2019 14:11 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/2 "2019-11-02T14:11:56Z")

</div>

How are you connecting your arduino to Node-RED?

Have you checked you are receiving anything using a debug node?

---

<div class="post-metadata">

**Author:** ![spen0203](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@spen0203](https://discourse.nodered.org/u/spen0203)\
**Post date:** [2 November 2019 14:14 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/3 "2019-11-02T14:14:06Z")

</div>

With the arduino connected it wont update it but with inject i get the proper out put, Im using a teensy 3.2 on pin 0 (digital read) and a push down configuration button. my breadboards correct so im a little confused on it

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [2 November 2019 14:39 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/4 "2019-11-02T14:39:21Z")

</div>

As @ukmoose has asked

How are you connecting your teensy to a computer running Node-RED (and what type of computer - Pi/Win/Mac?)

What node are you using to feed information from your Teensy into Node-RED?

---

<div class="post-metadata">

**Author:** ![spen0203](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@spen0203](https://discourse.nodered.org/u/spen0203)\
**Post date:** [2 November 2019 14:53 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/5 "2019-11-02T14:53:35Z")

</div>

Currently directly with Windows using COM5 port with usb direclty to it

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2019 15:12 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/6 "2019-11-02T15:12:00Z")

</div>

And which node are you using in Node-RED?  
Attach a debug node to this node.  
When you press your button what do you see in the debug node? (cut and paste it here)

---

<div class="post-metadata">

**Author:** ![spen0203](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@spen0203](https://discourse.nodered.org/u/spen0203)\
**Post date:** [2 November 2019 15:52 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/7 "2019-11-02T15:52:43Z")

</div>

# Welcome to Node-RED

2 Nov 11:25:29 - [info] Node-RED version: v1.0.2  
2 Nov 11:25:29 - [info] Node.js version: v10.16.3  
2 Nov 11:25:29 - [info] Windows\_NT 10.0.17134 x64 LE  
[debug:bbeb59b8.42ed58] 0

if i put it to any pin it doesnt seem to output anything ti debug after the arduino in

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2019 16:10 UTC](https://discourse.nodered.org/t/using-a-button-to-trigger-an-led-question/17437/9 "2019-11-02T16:10:22Z")

</div>

Does the arduino node show that it is connected
