» Electronics » Arduino »Time to work button

Button "Time to work"



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.

Button


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.
6.6
7.5
7.2

Add a comment

    • smilesmilesxaxaokdontknowyahoonea
      bossscratchfoolyesyes-yesaggressivesecret
      sorrydancedance2dance3pardonhelpdrinks
      stopfriendsgoodgoodgoodwhistleswoontongue
      smokeclappingcraydeclarederisivedon-t_mentiondownload
      heatirefullaugh1mdameetingmoskingnegative
      not_ipopcornpunishreadscarescaressearch
      tauntthank_youthisto_clueumnikacuteagree
      badbeeeblack_eyeblum3blushboastboredom
      censoredpleasantrysecret2threatenvictoryyusun_bespectacled
      shokrespektlolprevedwelcomekrutoyya_za
      ya_dobryihelperne_huliganne_othodifludbanclose
9 comments
Dan
For many users who never turn off a working computer, Win + L would be more relevant.
I don’t know what it closes for you there, after closing everything that’s open for me, Alt + F4 brings up the shutdown window, pressing it again closes it
And so you can push to the end of the world
Taras
You cure yourselves, if you take instead of an experiment to judge what you don’t know. Alt + f4 - universal the “close” command, which closes after all butts are closed in turn, and the system itself.
Bender39
I thought it was only I know
Now there are two of us! friends
I thought it was only I know smile but it says here that it's a miracle instead of ALT + F4
[quote = Korolev] If you briefly press the computer’s power button, the standard “Shutdown” procedure will start and the computer will turn off normally.
I thought it was only I know smile but the article says about ALT + F4
Bender39
Alt + F4 to close the active program
If you briefly press the computer’s power button, the standard “Shutdown” procedure will start, and the computer will turn off normally. smile
Alt + F4 to close the active program, let it attach such a button to his head, there will be many times more benefits
If I understand correctly, is all this crap just to turn off the computer? It also takes a USB port!
Perhaps he will convince you to repeat this design.
A very useful thing, as soon as I did without it? scratch

We advise you to read:

Hand it for the smartphone ...