Turn off PC with digispark atttiny85

Hi!

For a project I am trying to shut a PC down with the following scan codes:

Set-1 make/brake Set-2 make/brake
Power e0 5e / e0 de e0 37 / e0 f0 37
Sleep e0 5f / e0 df e0 3f / e0 f0 3f
Wake e0 63 / e0 e3 e0 5e / e0 f0 5e

I've asked this question over several forums. But I can not get it to work. I've managed to shut the PC down with a CMD command. So when I press a button the Arduino will send a keyboard.press. That works but I really have to use the above called codes. Futher I tried to define the power management key's in the USB keyboard library by adding power/sleep/wake = 0x81/0x82/0x83 . But unfortunately the Arduino IDE doesn't recognize them: they stay black while the standard keys turn blue.

My question is: how can I simulate the power management key's? I think it is good to mention that I am a beginner at this. Anyone have example code ? My code:

/*
 * Comment out the line for your layout
 */

//#define LAYOUT_US_ENGLISH // Is default
//#define LAYOUT_CANADIAN_FRENCH
//#define LAYOUT_CANADIAN_MULTILINGUAL
//#define LAYOUT_DANISH
//#define LAYOUT_FINNISH
//#define LAYOUT_FRENCH
//#define LAYOUT_FRENCH_BELGIAN
//#define LAYOUT_FRENCH_SWISS
//#define LAYOUT_GERMAN
//#define LAYOUT_GERMAN_MAC
//#define LAYOUT_GERMAN_SWISS
//#define LAYOUT_ICELANDIC
//#define LAYOUT_IRISH
//#define LAYOUT_ITALIAN
//#define LAYOUT_NORWEGIAN
//#define LAYOUT_PORTUGUESE
//#define LAYOUT_PORTUGUESE_BRAZILIAN
//#define LAYOUT_SPANISH
//#define LAYOUT_SPANISH_LATIN_AMERICA
//#define LAYOUT_SWEDISH
//#define LAYOUT_TURKISH
//#define LAYOUT_UNITED_KINGDOM
//#define LAYOUT_US_INTERNATIONAL
#include "DigiKeyboard.h"


void setup() {
    DigiKeyboard.enableLEDFeedback();
}
void loop() {

    DigiKeyboard.sendKeyStroke(0);
    DigiKeyboard.delay(1000);
    DigiKeyboard.sendKeyStroke(0x81,0x81 | 0x81);
    DigiKeyboard.delay(10);
    DigiKeyboard.sendKeyPress(0,0);
    DigiKeyboard.delay(50000);    
}



Can you explain what you intended this line to do?

@PaulRB this line send the 0x81 sequence, to power off. 0x81 is USB Hex code, more info Keyboard scancodes: Keyboard scancodes

I see 0x81 mentioned in section "1.1 Key Release" on that page, but not under the "1.9 Power Saving" section.

Why is 0x81 used 3 times in that code line? What is the second parameter of that function used for, and why is the bit-wise-OR used? Did you know that for any value x, x | x == x ?

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