Digispark left click help

Would anyone here know how to code a digispark to simulate a left click when ever I press the button I have soldered to pin 0 and ground? The code I found doesn't seem to work, it keeps sending "a" and will send them more if I press the key. `#include "DigiKeyboard.h"

void setup() {
pinMode(0, INPUT);
}

void loop() {
if(digitalRead(0)==LOW){
DigiKeyboard.sendKeyStroke(KEY_A);
}
delay(500);
}`

There are posting rules for the forum.


Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.


Try pin 2 and use:
pinMode(2, INPUT_PULLUP);

A "Left Click" is a MOUSE thing, not a KEYBOARD thing. Do they provide a Mouse library?

#include <DigiMouse.h>

void setup() {
  pinMode(2, INPUT);
  DigiMouse.begin();
}

void loop() {

  if(digitalRead(2)==LOW){ 
    DigiMouse.leftClick();
    DigiMouse.delay(500);
  }
}
``` I have my key soldered to pin 2 and ground know

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.