I've got a LCD driver board (with some push buttons to open menu/+/-) and a bi-directional HDMI switch (with a latch button to redirect HDMI output to one or another) where I want to remove those buttons and command them via a teensy 2+ I bought. Do I just need to wire board GND and switch GND to teensy and do: (let set PIN_D5 is connected to the lcd board button menu and PIN_D6 to the latch button)

In loop function:

pinMode(PIN_D5, OUTPUT); 
digitalWrite(PIN_D5, LOW); 
digitalWrite(PIN_D5, HIGH); 

to simulate a momentary push


pinMode(PIN_D6, OUTPUT); 
digitalWrite(PIN_D6, LOW);

to simulate a maintained push ?


1 Answer 1


Declaring pin modes should remain in the setup function, as it shouldn't change during the program.

Also, you can keep the button state in a variable and change it later as you simulate a push :

bool btnState = false;
// ...
      pinMode(PIN_D5, OUTPUT);
      pinMode(PIN_D6, OUTPUT);

void switchButton(){
  btnState = !btnState;
  digitalWrite(PIN_D6, btnState);


If you want to simulate a momentary pushed button, you may need to wait a little while between pressing and releasing a given button as below :

void pressButton(int button){
  digitalWrite(button, HIGH);
  digitalWrite(button, LOW);

NB : depending on your LCD driver board logic, you may need to change HIGH level to LOW and vice-versa

  • \$\begingroup\$ thank you for your answer, pinMode must be in setup you're right. I can then simulate every push button just by using digitalWrite then ? \$\endgroup\$
    – Frntz
    Commented Mar 15, 2018 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.