Laptop control using Arduino

I am working on a rather simple project where I hook up an arduino UNO to my laptop. There is an ultrasonic sensor connected to the arduino. I require the arduino to send a signal which turns off the display whenever I move away from my laptop and turn on the display as soon as I approach it. I will use an algorithm like : When distance measured by the sensor is less than 1 meter, turn on the display otherwise turn off the display. Please provide a basic sample code. Any help would be appreciated. I'm open to new suggestions as well.

You will need an Arduino Leonardo in order to do that. So far none of the other Arduino’s can interface with keyboard commands, so if anything that’s where you should start.

Now if your computer has a sleep and wake button, I would see if there is a way you can make hot-keys for them, or see if you can make the key combination yourself with the libraries available keys.

If you able to figure out the hot-key / key combination , then the next part should not be difficult to implement.

HazardsMind: You will need an Arduino Leonardo in order to do that. So far none of the other Arduino's can interface with keyboard commands, so if anything that's where you should start.

Now if your computer has a sleep and wake button, I would see if there is a way you can make hot-keys for them, or see if you can make the key combination yourself with the libraries available keys.

If you able to figure out the hot-key / key combination , then the next part should not be difficult to implement.

Thanks for the reply. I was thinking that it'd work this way : When the sensor detects the person in one meter range, the arduino will send a value through the serial port. (the arduino is always connected to the laptop). Now somehow, I'll have to decode the received serial value to make the computer turn off the display or turn it on or maybe sleep and wake up. Can it be done using Arduino UNO? Because I am not directly using any keyboard command. I am just receiving a serial value and then telling my computer to act on the basis of received value.

Can it be done using Arduino UNO? Because I am not directly using any keyboard command. I am just receiving a serial value and then telling my computer to act on the basis of received value.

That, I can’t say because I don’t know if your computer/laptop will be able to receive serial commands when it is sleeping.

HazardsMind:

Can it be done using Arduino UNO? Because I am not directly using any keyboard command. I am just receiving a serial value and then telling my computer to act on the basis of received value.

That, I can't say because I don't know if your computer/laptop will be able to receive serial commands when it is sleeping.

Ahh, I get it now. You are right. I'll do some more research and let you know.