Arduino 105 - Slightly more than the basics (Infrared Recieve/Send) (Graphic LCD) and a (RGB LED) :)

So I bought a Mega128 kit from Honk kong including a KS0108 based GLCD 128x64 (8192pixels total)

When i got the kit the GLCD was already so nicely wired in for me and I did not have to mess around with
Raspberry Pi Server Essentials Book
Buy Raspberry Pi Server Essentials.
A great Arduino alternative!
that.

In the beginning I was just messing around with the basics, LEDs, potentiometers, piezzo buzzer and some erratic code to do weird stuff that had no benefit what so ever.

I got hold of the include IR receiver and plugged that in at tried to work out how to wire it up. (Also is how to wire in the transmitter; but that is later)

VCC :2V-5.5V
OUT :  pin11 can be any PWM pin you choose and that can be defined inside the arduino IDE

OBJECTIVE

Now the whole object of this exercise is to use the GLCD Library (Version 3 Beta at this time) and the Infrared and see what I can put together. Bearing in mind I have never used Arduino in my life.

PRACTICALITY
I have a Sony Alpha dSLR and a simple remote I bought from HK for £1 to trigger a shot or delayed 2s shot. My model only has these two function.Luckily Kens library knows how to decode SONY signals.

So what I did is decoded the sony remote button to take a instant snapshot.

 Then I hard coded that code into a function in my sketch and programmed it that when i press the "MODE" button it will tell my camera to do an instant snap shot. I also put a 2pin(has a built in timer that cycles through colours-normal RGB's have 4 pins) RGB light on the breadboard and when I press "POWER" it will give a HIGH output and the led will stay on until I press another  button on the remote and it will cycle and look cool.

Also - using any remote it will show you the raw long integar value if decoded by Kens library. As you will notice in the you-tube lower, my media centre remote gave allot of "0" values which is not good I suppose.

Every time a signal is detected the RGB led will flash briefly (by default the first colour in the cycle is red, so it flashes red) and with this a HEARTBEAT bitmap (4x5) graphic blinks in the 2 and 3 text line of the GLCD

This just proves how many things you can do with the Arduino and the best thing is that are allot of great people developing tons of new stuff there to tinker with. Thanks and Enjoy





To get this project working you will need.


Open Source Libraries
GLCD Version 3 Beta
Ken Shiriff's IR Library
*Extract/Install/Copy these to the library directory of Arduino program.


irCodes.h


/*************************************************
 * Public Constants for Generic Remote HK
 *************************************************/

 const unsigned long POWER   = 33441975;
 const unsigned long MODE    = 33446055;
 const unsigned long MUTE    = 33454215;
 const unsigned long PLAY    = 33456255;
 const unsigned long REWIND  = 33439935;
 const unsigned long FORWARD = 33472575;
 const unsigned long EQ      = 33431775;
 const unsigned long VOL_DOWN= 33464415;
 const unsigned long VOL_UP  = 33448095;
 const unsigned long ZERO    = 33480735;
 const unsigned long RPT     = 33427695;
 const unsigned long USD     = 33460335;
 const unsigned long ONE     = 33444015;
 const unsigned long TWO     = 33478695;
 const unsigned long THREE   = 33486855;
 const unsigned long FOUR    = 33435855;
 const unsigned long FIVE    = 33468495;
 const unsigned long SIX     = 33452175;
 const unsigned long SEVEN   = 33423615;
 const unsigned long EIGHT   = 33484815;
 const unsigned long NINE    = 33462375;


 char IR_POWER[]        = "POWER";
 char IR_MODE[]         = "MODE";
 char IR_MUTE[]         = "MUTE";
 char IR_PLAY[]         = "PLAY";
 char IR_REWIND[]       = "REWIND";
 char IR_FORWARD[]      = "FORWARD";
 char IR_EQ[]           = "EQ";
 char IR_VOL_DOWN[]     = "VOLUME DOWN" ;
 char IR_VOL_UP[]       = "VOLUME UP";
 char IR_ZERO[]         = "ZERO";
 char IR_RPT[]          = "RPT";
 char IR_USD[]          = "U/SD";
 char IR_ONE[]          = "ONE";
 char IR_TWO[]          = "TWO";
 char IR_THREE[]        = "THREE";
 char IR_FOUR[]         = "FOUR";
 char IR_FIVE[]         = "FIVE";
 char IR_SIX[]          = "SIX";
 char IR_SEVEN[]        = "SEVEN";
 char IR_EIGHT[]        = "EIGHT";
 char IR_NINE[]         = "NINE";
 char IR_UNKNOWN[]      = "UNKNOWN";  //Dont change or leave long space after to clear any other text.




bitmaps.h - a modified version of the GLCD rockets example bitmap.h ;)


#include
#include

static uint8_t heart [] PROGMEM = {
5,
8,
0x08, 0x1C, 0x38, 0x1C, 0x08,

};




My Sketch Code


Too long to post - All this is available in a download at the end of the post with references


I spent some time writing the irCodes.h and this can be used together with the remote that is provided from the HK supplier. I dont know what standard it uses because the the example program "recorder" cannot decode it and supplies raw codes only. This file however provides you with quick reference to what the long value of each button is and you can include it in your sketch and use the pre defined values and even strings.

In total I spent about 8 hours working the kinks out of this prototype. So all I can offer now are some hints on some stuff I got stuck and a bit frustrated.

HINTS:

  1. Use a 100Ohm resistor with the IR Led
  2. Using raw IR code is not simple. If you want to send raw IR use the example provided in Ken Shirrifs library "Recorder" - Run it and read the terminal. If it recognises your remote it will display a HEX value(remember to send the value you need the long int not HEX and the Length) - If not it will show you a long string of RAW Array. Tweak the example to show you integer instead of HEX.
  3. Receiving signals on all models is easy. To receive using the mega 128/256 kit you to initialise a PWM pin. On the older models the output pin is 3. You cannot change this easily. On the Mega its going to be pin 9 but you have to do this in setup.
     pinMode(9,OUTPUT);
     digitalWrite(9, LOW);
  4. When recieving and sending IR signals using Kens library you need to remember one important thing that is not obvious. If you are receiving IR signals and in the mean time you send 1 IR procedure you MUST restart the irrecv function.
    irrecv.enableIRIn();
    You cannot send and receive at the same time.... This took me a while to figure out as it was not written on Ken's page.
  5. The GLCD Ver 3 Library is 100% faster than the Ver 2!! I got my LCD to 20FPS
  6. It is faster to fill a space on your GLCD that needs "clearing" than clearing the whole screen and redrawing the entire frame. So, just draw what you need, clearing is also drawing.
  7. Use CASE instead of IF- Saves ram and is faster.
  8. You will notice on the video that I press MODE several times and the Arduino decodes and understands it. It also broadcasts the SONY Instant snapshot IR signal but the camera does not take a picture even though its right in front of the IR LED. While I was doing research some body wrote it will be better to put in a NPN transistor to boost the AMP's, as Arduino gives something like 20~40mW and the IR-LED needs like 100mW to operate the best. That will improve range and decrease IR noise. The same guy suggested using 2 or more IR-LED to improve broadcasting quality and range. Another thing is that Sony IR signal need to be sent 3 times but devices respond after 2 successful clear codes have been sent to prevent cross noise but you need to have a good transmitter. 
DEMONSTRATION


REFRENCES


All the code

Comments