# First time using buttons

**URL:** https://discourse.nodered.org/t/first-time-using-buttons/78974
**Category:** General
**Created:** [5 June 2023 19:50 UTC](https://discourse.nodered.org/t/first-time-using-buttons/78974 "2023-06-05T19:50:47Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [5 June 2023 20:50 UTC](https://discourse.nodered.org/t/first-time-using-buttons/78974/3 "2023-06-05T20:50:06Z")

</div>

It's only natural for someone who comes to Node-red with a bit of programming knowledge to leap into the function node. After all, it's the only bit that looks like a program.  
However, this is generally not a very good idea.  
It's like buying a comprehensive toolbox, throwing away all the tools except the hammer and using it to make your own.

> [@spawnreaper](#):
>
> Button 1 needs to switch relay1 on for 40 ms and then turn off again.

Yes, a trigger node is the solution here. This flow might look something like this:

 ![Untitled 10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bd604538eb482965b06a0fa9168ecbeb6337965.jpeg)  
What does your version look like?  
If you have GPIO-in nodes, these will reflect the actual pin status. Have you chosen appropriate pins? Have you configured pull-up/down resistor options?  
Definitely don't copy my pin selection, it's random.

> [@spawnreaper](#):
>
> I can make a ON injection and OFF injection to switch the relays on and off. But making a single button action that turns it on when its off and off when its on, I cant figure out.

There is a discussion about that at [https://discourse.nodered.org/t/toggle-gpio-input/60643/7](https://discourse.nodered.org/t/toggle-gpio-input/60643/7)

> [@spawnreaper](#):
>
> p.s. i havent wired up the relay or the buttons because i want to be safe. I am also not sure if I need to add resistors to the buttons or not.

Do not wire up physical buttons or relays until you are sure. There are countless tutorials on [raspberrypi.com](http://raspberrypi.com) and it's associated sites, youtube and elsewhere.

> [@spawnreaper](#):
>
> Ive asked chatgpt to help me out with some code to put into a function but I keep getting the same error

So you asked an infinite number of monkeys to write you a program and it didn't go well. How surprising is that? 😄

---

_[View the full topic](https://discourse.nodered.org/t/first-time-using-buttons/78974)._
