I was trying to read an IR remote signal using Arduino UNO.
The idea is to create a Wireless PowerPoint Slide Changer.
The keyboard functions required for this purpose, I found, won't work with UNO!
Is there any way out of it besides purchasing an Arduino Micro?
Yes, but they would be far more complex and more expensive than using a Micro (or Leonardo).
PaulRB:
Yes, but they would be far more complex and more expensive than using a Micro (or Leonardo).
Ok but what exactly is the alternative?
Actually, the UNO is perfectly able to function as a HID by reprogramming the ATmega8U2 USB interface chip. That is the exact reason for the design.
This may help.
Thank You so much
Ok so I tested everything up and its working...but just the LEDs !!
Code is working fine, don't know what scan codes to send to computer !
Used this http://www.computer-engineering.org/ps2keyboard/scancodes2.html list but nothing working :~
What is wrong with this code?
#include <IRremote.h>
//initializing the pin
int recv_pin = 2;
int led = 13;
//Defining hex values for keyboard
const byte MAKE = 0xE0;
const byte BREAK = 0xF0;
const byte RightArrow = 0x74;
const byte LeftArrow = 0x6B;
//Defining pre-read IR remote key data
const long RIGHT_ARROW_DEC = 2160034684;
const long LEFT_ARROW_DEC = 2160040294;
//Class performing the decoding function
IRrecv irrecv(recv_pin);
//Decoding the results
decode_results results;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
//Enabling the IR Receiver
irrecv.enableIRIn();
}
void loop()
{
//Checking if any value received
if(irrecv.decode(&results))
{
//Printing the HEX value of the IR signal received
Serial.println(results.value, DEC);
//Checking which key is pressed and taking desired action
if(results.value == RIGHT_ARROW_DEC)
{
glowLed();
makeKey(MAKE, RA);
breakKey(MAKE, BREAK, RA);
}
else if(results.value == LEFT_ARROW_DEC)
{
glowLed();
makeKey(MAKE, LA);
breakKey(MAKE, BREAK, LA);
}
//Preparing the receiver for next signal
irrecv.resume();
}
}
void glowLed()
{
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
}
void makeKey(byte val1, byte val2)
{
Serial.write(val1);
Serial.write(val2);
}
void breakKey(byte val1, byte val2, byte val3)
{
Serial.write(val1);
Serial.write(val2);
Serial.write(val3);
}
The long constants should have an "L" after them?
Thanks PaulRB
Although I hadn't used that 'L' before, the LED was (is) blinking. No problem there.
The problem I am facing right now is the keyboard simulation.
Dunno why my makeKey() and breakKey() aren't working !!
ok so after some intense lookup i edited my code to this:
#include <ps2dev.h> //Library to emulate keyboard
#include "Arduino.h"
#include <IRremote.h>
PS2dev keyboard(3,2); // PS2dev object (2:data, 3:clock)
//initializing the pin
int recv_pin = 2;
int led = 13;
//Defining hex values for keyboard
//const byte MAKE = 0xE0;
//const byte BREAK = 0xF0;
//const byte RA = 0x74;
//const byte LA = 0x6B;
//Defining pre-read IR remote key data
const long RIGHT_ARROW_DEC = 2160034684;
const long LEFT_ARROW_DEC = 2160040294;
//Class performing the decoding function
IRrecv irrecv(recv_pin);
//Decoding the results
decode_results results;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
//Enabling the IR Receiver
irrecv.enableIRIn();
}
void loop()
{
//Checking if any value received
if(irrecv.decode(&results))
{
//Printing the HEX value of the IR signal received
//Serial.println(results.value, DEC);
//Checking which key is pressed and taking desired action
if(results.value == RIGHT_ARROW_DEC)
{
glowLed();
keyboard.write(0xE0);
keyboard.write(0x74);
keyboard.write(0xE0);
keyboard.write(0xF0);
keyboard.write(0x74);
}
else if(results.value == LEFT_ARROW_DEC)
{
glowLed();
keyboard.write(0xE0);
keyboard.write(0x6B);
keyboard.write(0xE0);
keyboard.write(0xF0);
keyboard.write(0x6B);
}
//Preparing the receiver for next signal
delay(500);
irrecv.resume();
}
}
void glowLed()
{
digitalWrite(led, HIGH);
delay(20);
digitalWrite(led, LOW);
delay(20);
}
and yes i have deleted the line #include "Wconstants.h"
and replaced it with #include "Arduino.h"
Still no success =(