• sales

    +86-0755-88291180

code for esphome , gpio for K1 and K2

2025-01-25 00:56:46 Ask

hi

i wander how to code the action after pressing K1 or K2

could you confirm the pin number to use for  'on press event'  ?


regards


2answers
SpotPearGuesta4c05
Answer time:
2025-08-23 07:55:43

Use on_click:

<

# key 1:

- platform: gpio

pin:

number: GPIO8

mode:

input: true

pullup: true

inverted: true

id: key1

internal: True

on_click:

- min_length: 0 s

max_length: 500 ms

then:

>


<  # key 2:

 - platform: gpio

   pin:

     number: GPIO10

     mode:

       input: true

       pullup: true

     inverted: true

   id: key2

   internal: True

   on_click:

     - min_length: 0 s

       max_length: 500 ms      


Like0

report

Price: $9.99
Part Number: ESP32C3-1.44
Brand: Spotpear