One of my old computers is used as a file backup server in my basement office. It is kept off most of the time and only powered on when I needed to sync up files. Unlike most of the computers nowadays, this old DELL computer does not have a Wake On LAN (WOL) compatible network card. And thus, it makes turning on the computer less than convenient.

So, I thought why not build a remote control for it myself? I quickly put together a circuity (see below) and with a few lines of code, I was able to control the rely using one of my spare remote controls within several feet.

IR Switch using Arduino
IR Switch using Arduino

The relay terminals (1 and 2) connect in parallel to the main power switch on my computer.

Here is the Arduino code listing:

#include <IRremote.h>
#include <TimerOne.h>

int RECV_PIN = 11;
int RELAY_PIN = 10;
int LED_PIN = 12;

boolean signaled = false;
unsigned long counter = 0;

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);
  pinMode(LED_PIN, OUTPUT);
  
  //polling every 200 ms
  Timer1.initialize(200000L); 
  Timer1.attachInterrupt(callback);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {            
    signaled = true;
    if (signaled) {
      Serial.println("ON");
      digitalWrite(RELAY_PIN, HIGH);
      digitalWrite(LED_PIN, HIGH);
      counter = 0;
    }
   
    irrecv.resume(); // Receive the next value
  }
}

void callback()
{
  if (signaled) { //blink the LED
    counter++;
    digitalWrite(LED_PIN, counter % 2);
  }
  
  //hold the relay for 2 seconds
  if (counter > 10) {
    signaled = false;
    counter = 0;
    digitalWrite(RELAY_PIN, LOW); 
    digitalWrite(LED_PIN, LOW);   
    Serial.println("OFF");
  }
}

I used a modified Ken Shirriff’s IR remote control library. The simple modification I made (see code below) allows me to use any of the keys on the the remote control I have to turn on and off the computer.

#define DAW 5
#define DAW_BITS 17
#define DAW_HDR_MARK 8000

long IRrecv::decodeDAW(decode_results *results) {
  long data = 0xf;
  int offset = 0;

  if (!MATCH_MARK(results->rawbuf[offset], DAW_HDR_MARK)) return ERR; 
  offset++;
  // Success
  results->bits = DAW_BITS;
  results->value = data;
  results->decode_type = DAW;
  return DECODED;
}
Be Sociable, Share!