The one button logout.
This is an old project. It started with the game at work that if you forgot to logout, people would write emails in your name inviting the entire office to cake.
Micro controller.
For this to work you need something that can can act as i HID like a keyboard. the Arduino micro can do that. You simply plug it in to the pc and it will act like it a keybord.
#include "Keyboard.h"
int led = 3;
int button = 2;
int brightness = 0;
int fadeAmount = 5;
void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(led, OUTPUT);
Keyboard.begin();
}
void loop() {
//keep looping until the button is pressed.
while (digitalRead(button) == HIGH) {
analogWrite(led, brightness);
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
writeMessage();
blink(3);
}
// press windows + l and lock
void writeMessage(){
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('l');
delay(10);
Keyboard.releaseAll();
}
void blink(int count){
for(int i = 0; i<count; i++){
analogWrite(led, 100);
delay(200);
analogWrite(led, 0);
delay(200);
}
}
Now all we need is to find a big red button. and wire the button up to pin 2 and the led to pin 3
Prototype case
Some project never get to the case, but here we are.
This have been in the garage for years, but when writing this up we might as well get it finished.