HI all,
my project is to power on/shutdown my pc using the TV remote control.
The power off operation is easy to perform with Leonardo, simulating the sequence of keys in order to press the shutdown button.
The problem is the power on operation: I set my pc to power on when a USB keyboard's key is pressed, but when I simulate the press of a key nothing happens
I tried also to wakeup my pc with the mouse click, but with same results.
#include <IRremote.h>
int RECV_PIN = 11;
int num_off=0;
int num_on=0;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
//Power OFF
if(results.value==0xE0E0F10E)
num_off++;
if(num_off>20){ //If I receive at least 20 0xE0E0F10E I shutdown my pc
num_off=0;
Keyboard.begin();
// CTRL-ALT-DEL:
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_ALT);
Keyboard.press(KEY_DELETE);
delay(100);
Keyboard.releaseAll();
//ALT-s:
delay(1000);
Keyboard.press(KEY_LEFT_ALT);
Keyboard.write('s');
//ALT-a:
Keyboard.write('a');
delay(100);
Keyboard.release(KEY_LEFT_ALT);
Keyboard.end();
}
//Power ON
if(results.value==0xE0E0926D)
num_on++;
if(num_on>20){ //If I receive at least 20 0xE0E0926D I power on pc pressing a key
num_on=0;
Keyboard.begin();
Keyboard.press(KEY_LEFT_CTRL);
delay(100);
Keyboard.release(KEY_LEFT_CTRL);
Keyboard.end();
}
irrecv.resume(); // Receive the next value
}
}
Someone who has Leonardo can try if he can power on the PC simulating a button pressure? In this way I can understand if it's a arduino problem or it's a my pc problem....