Blog Archive

Thursday 24 January 2013

Turning on Zotac PC with Infrared

I hooked this Arduino setup to my Zotac PC to allow me to switch it on when it was shutdown using an old Sony infrared remote control. It gets its power direct from the 20v feed in the PC and is connected to the back of the power button on the front of the PC.

Here's a piccy:

Here's the code.

#include <IRremote.h>  
   
 int RECV_PIN = 2;  
   
 int Powerpin = 8;  
 int LEDreceivePin = 3; // Flash LED when IR signal received.  
   
 IRrecv irrecv(RECV_PIN);  
   
 decode_results results;  
   
 void setup()  
 {  
  Serial.begin(9600);  
  irrecv.enableIRIn(); // Start the receiver  
  pinMode(Powerpin, OUTPUT);   // sets the digital pin as output  
  pinMode(LEDreceivePin, OUTPUT);   // sets the digital pin as output  
  Serial.println("begin...");  
 }  
   
 void loop() {  
  if (irrecv.decode(&results)) {  
   long int decCode = results.value;  
   Serial.println(decCode);  
     digitalWrite(LEDreceivePin, HIGH);  
     delay(125);  
     digitalWrite(LEDreceivePin, LOW);  
   switch (results.value) {  
       
     case 2704:  
     Serial.println("POWER");  
     digitalWrite(Powerpin,HIGH);  
     delay(1000);  
     digitalWrite(Powerpin,LOW);  
     break;  
       
    case 428895:  
     Serial.println("Stop");  
      digitalWrite(Powerpin, LOW);  // sets the LED off  
     break;   
     
    default:  
     Serial.println("Waiting ...");  
   }  
   
   irrecv.resume(); // Receive the next value  
  }  
 }  
All stolen from here: http://arduinotronics.blogspot.it/2012/11/arduino-ir-receiver-part-2.html