↩ Back to Home

Digispark lock btn

Ok here is the code for locker button. The main feature of this device is to lock the screen of the computer when you leave the office.

#include "DigiKeyboard.h"

const int buttonPin=0;
int buttonState=0;

void setup() {

  DigiKeyboard.update();
  DigiKeyboard.sendKeyStroke(0);
    
  pinMode(buttonPin, INPUT);
}

void loop() {

  buttonState=digitalRead(buttonPin);

  if (buttonState == HIGH) {
    DigiKeyboard.sendKeyStroke(KEY_L, MOD_GUI_LEFT);
  }
}