Mohannad Rawashdeh
Published © CC BY-NC

IR Remote Control and Arduino Control AC Voltage Device

Simple instruction to let you know how to control an AC voltage device using an IR remote control and the Arduino.

BeginnerProtip1 hour22,088
IR Remote Control and Arduino Control AC Voltage Device

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
IR receiver (generic)
×1
Sugar device
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1
Resistor 475 ohm
Resistor 475 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematic IR

Code

IR switch on off code

Arduino
/*
 * Copyright 2009 Ken Shirriff
   Modifiy by M. Rawashdeh
   Sugar device Switch ON OFF application
 */

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int SugarPin=9;
const int LEDpin=8;
boolean Power=false;
void setup()
{
//  Serial.begin(115200);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(SugarPin,OUTPUT);
  pinMode(LEDpin,OUTPUT);  
}

void loop() {
  if (irrecv.decode(&results)) {
//   Serial.println(results.value, HEX);
switch(results.value)   
{
  case 0xFB38C7:
  // power on/OFF
  Power= !Power;
  if(Power)
  {
   analogWrite(SugarPin,64) ;
   digitalWrite(LEDpin,HIGH);
   }
  if(!Power)
  {
   analogWrite(SugarPin,12) ;
   digitalWrite(LEDpin,LOW);
  }
  delay(1500);
  break;
  }
  irrecv.resume(); // Receive the next value  
}
}

Test IR code

Arduino
/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 *  http://arcfn.com

 */

#include 

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }

}

Credits

Mohannad Rawashdeh

Mohannad Rawashdeh

3 projects • 15 followers
Mohannad Rawashdeh is an Entrepreneur,and electrical Engineer from Jordan. Founder of Sugar device. http://www.sugarworld.net/

Comments