Go Down

Topic: Making a Computer Control Panel (Read 1 time) previous topic - next topic

BrandonR

#5
Jun 25, 2011, 10:35 pm Last Edit: Jun 25, 2011, 10:37 pm by BrandonR Reason: 1
An update: thanks to the suggestion of using Gobetwino, I was able to do a proof-of-concept that locked the computer with the push of a button. It's a standard pushbutton circuit, and here's the coding:

Code: [Select]
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status


void setup() {
 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);      
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);
 
 // define serial pins
 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);
 Serial.begin(9600);
}

void loop(){
 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);

 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
 
 if (buttonState == HIGH) {    
   // turn LED on:    
   digitalWrite(ledPin, HIGH);  
     
 }
 else {
   // turn LED off:
   digitalWrite(ledPin, LOW);
   
   // LOCKCOMP is the Gobetwino command with the SPRID command
   // for program/cmd line arg. C:\Windows\System32\rundll32.exe User32.dll,LockWorkStation
   Serial.println("#S|LOCKCOMP|[]#");
   
   // prevent more than one command being sent
   delay(3000);
 }
}


Originally I was going to use a sendkeys (sendk) command for the Windows Key+L since this locks the workstation, but apparently the Windows Key is somewhat tricky to send through sendkeys. Anyway, this method is more direct and more elegant than relying on keystrokes.

With that in place, creating additional commands, adding better buttons, and the bells/whistles like flashing indicator lights should be relatively easy. Suggestions are welcome!

Go Up