Suggested by author Instructables under the nickname fmtuve homemade It is a button from the bottle cap, which must be pressed at the end of the working day. It simulates the pressing of the Cmd + Q keyboard shortcut, which on Mac OS X performs the same function as the well-known Alt + F4 combination on Linux and Windows. The device case is 3D-printed, electronics executed on Arduino Pro Micro. And it seems that the master put the production of such devices on stream:
All components of the homemade product are shown below, of which the three parts located on the right are 3D-printed, STL files for printing them are in this ZIP archive.
Having printed the details of the case, the master solders the combs to the Arduino in an unusual way - from the components side:
Puts in this recess in the bottom of the hull:
It turns out as on KDPV in the upper right corner:
Inverting the middle part of the case, puts a button in it, cuts in half a jumper of the “duPont” type and solders to the contacts of the button, isolates the connection with a heat shrink tube:
Turns the middle part together with the button back, connects it to the bottom, connects the button to the GND and A8 Arduino pins. A pull-up resistor would not hurt here, but it would work without it.
Then the wizard adds to the button the top 3D-printed part-pusher:
Writes a sketch:
The text is as follows:
#include
#include
// connected PIN8
const int switch_pin = 8;
int button_state = 0;
int previous_button_state = HIGH;
long last_debounce_time = 0;
const long debounce_delay = 50;
void setup ()
{
// We use internal pullup registor 'cause the switch directly connected.
pinMode (switch_pin, INPUT_PULLUP);
digitalWrite (switch_pin, HIGH);
Keyboard.begin ();
}
void loop ()
{
button_state = digitalRead (switch_pin);
if ((button_state! = previous_button_state) && (button_state == HIGH))
{
if ((millis () - last_debounce_time)> debounce_delay)
{
// Exit Program (CMD + Q in mac) & Have a nice day!
// Use KEY_LEFT_ALT + KEY_F4 for PC
Keyboard.press (KEY_LEFT_GUI);
Keyboard.press ('q');
delay (100);
Keyboard.releaseAll (); // This is important after every Keyboard.press it will continue to be pressed
last_debounce_time = millis ();
}
}
previous_button_state = button_state;
}
Here it turns out that: if you turn on the built-in pull-up resistor in the sketch, the external one is not needed. In the text you need to change the keyboard shortcut to the one you need. After filling the sketch, the master installs a bottle cap on the pusher:
And he starts work on a small advertising poster:
Perhaps he will convince you to repeat this design. After all, the thing is positive, which will quickly begin to be associated with returning home from work.