How to make IR LED work with Arduino and IRRemote Library?

Hi,
I want use the IRRemote library with Arduino using the IR LED of littlebits, is that possible ?
How to make it to work? It seems IRRemote is using some specific pin number and the IR LED can connect use d3,

Hi @JohnLi,
Do you want to use the IR LED bit o7 to send signals or the IR trigger bit i7 to receive signals from a standard remote?

For the last option I made a small setup with the IR trigger bit i7 and I found out it does not transmit any codes generated by a remote control…
It just triggers its output high (+5Volt) or low (GND) when receiving a signal…

But there is another solution:
When you connect a different sensor to the HDK protobit it works !
I used the VS1838B sensor:

here you can see the result with a remote, using the buttons number 1, 2 and 3 to light up three different LEDs on the Arduino Leonardo:

For this sensor the IRremote library must be added to your IDE, see the following instructions for this:

These are the arduino programs I used for this test:

Using the VS1838B sensor:

/*

  • 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

  • updated for Littlebits Arduino leonardo bit W7 by Alex Pikkert

  • December 2015

  • Change the HEX codes that I used to match your own remote controller codes

  • (They can be detected by activating the serial print program lines)

  • The i7 IR remote trigger bit does NOT send the received codes, it just sends a HIGH or LOW signal.

  • I used a protobit with an IR trigger type VS1838B.
    */

    #include <IRremote.h>

int RECV_PIN = A0;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
//Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(1,OUTPUT);pinMode(5,OUTPUT);pinMode(9,OUTPUT);
}

void loop() {
if (irrecv.decode(&results)) {
//Serial.println(results.value, HEX);

switch (results.value) {
case 0xFF30CF:
digitalWrite(1,HIGH);delay(1000);digitalWrite(1,LOW);
break;
case 0xFF18e7:
digitalWrite(5,HIGH);delay(1000);digitalWrite(5,LOW);
break;
case 0xFF7A85:
digitalWrite(9,HIGH);delay(1000);digitalWrite(9,LOW);
break;

 default: 
   // if nothing else matches, do the default
   // default is optional
 break;

}
irrecv.resume(); // Receive the next value
}
}

Using the i7 Littlebits IR trigger:

/* IR trigger test program for Littlebits Arduino Leonardo W7

  • IR trigger bit I7 from Littlebits connected to input A0

  • Output D5 connected to RGB LED bit o3

  • Version 0 December, 2015

  • alexpikkert@gmail.com
    */

    #include <IRremote.h>

    #include <IRremoteInt.h>

void setup()
{
Serial.begin(9600);
pinMode(1,OUTPUT);digitalWrite(1, LOW);
pinMode(5,OUTPUT);digitalWrite(5, LOW);
pinMode(9,OUTPUT);digitalWrite(9, LOW);
}
void loop() {
if (digitalRead(A0)==1)
{
Serial.println(“Signal received,sorry no code available…”);
digitalWrite(5, HIGH);delay(1000);digitalWrite(5, LOW);
}
}

Hoping it helps… :grinning:

2 Likes

Hi, thanks for the information. It’s really interesting to see the demo.

I want use IRLED to send signal actually, if the IRRemote works with it, then that will be useful to control many things ( TV, IR Toy etc.).

I read the IRRemote code ( irSend.cpp ), not quite understand the hardware code, I am guesting the code want to setup some timer and make digital voltage to go at specific kHZ, then send HIGH and LOW to output to control IR LED send signal out. Not sure the IR LED o7 support these.

There’s also a new IR transmitter o18 http://littlebits.cc/bits/ir-transmitter , this seems have more features with 4 channel and ‘600 us long bursts of 38 kHz’, it seems still not work for the general programming IR sender.

void  IRsend::enableIROut (int khz)
{
	// Disable the Timer2 Interrupt (which is used for receiving IR)
	TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt

	pinMode(TIMER_PWM_PIN, OUTPUT);
	digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low

	// COM2A = 00: disconnect OC2A
	// COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
	// WGM2 = 101: phase-correct PWM with OCRA as top
	// CS2  = 000: no prescaling
	// The top value for the timer.  The modulation frequency will be SYSCLOCK / 2 / OCR2A.
	TIMER_CONFIG_KHZ(khz);
}

Hi @JohnLi,
looking at the bit diagram from the IR LED o7, I think this LED cannot send codes.
It has an opamp in the diagram so i think it probably will react in the same way as the IR trigger, just ON or OFF…
The o18 IR transmitter belongs to the AC power switch from the Smart Home Kit. It is designed to be paired with this switch only…

Hello @alexpikkert,

thanks a lot for all your inspiring projects and comments.

I think the opamp for the o7_irled is only a buffer, the following transistor will switch the ir LED on and off, according to the input signal. One thing that could be possible, is to have an oscillator bit before, running at 38kHz and switching the oscillator on and off with another bit, either the pulse bit or the arduino bit.

I haven’t tried it yet, as I currently more on the 2.4GHz wireless path. Would be interesting for me if someone could try this out.
The VS1838B is a nice fit for the littleBits universe.

rgs
7th Dwarf

1 Like

Hi @SeventhDwarf,
You are right about the opamp and the following transistor.
But I am not sure if this diagram will work at 38 kHz. I think it has been designed to just switch slowly ON/OFF. I am not able to test this… :sweat:
The Littlebits oscillator has been designed for the human audio range, so I think 38kHz is way too much…

Hi @JohnLi,
I found a nice tutorial on the adafruit website. They showed that the Arduino can generate the infrared pulse sequences used for sending the control pulse trains for gadgets like a camera.
See this site with nice examples:

If it does not work with the o7 IR led on the output side for sending these pulses, (due to the diagram above), then you could use a protobit connected to the arduino output with just a standard IR led with a resistor to send…
Maybe you can try this ?

Thanks @alexpikkert & @SeventhDwarf , I don’t have the protobit bit or oscillator bit now, and not quite good at these electronic detail stuff, so I can’t try these now.

I just found another easy way to try programming IR Remote control with Android or iOS phone IR library.

1 Like

Hi folks,

I’m quite late into this conversation, but check out the following project: littlebits-automated-railroad-bitify

They use the IR LED to control a LEGO train, so it seems possible to generate infrared pulses using that bit.

Seems like a realy good idea for a project. Does the long LED bit have the same schematics as the o7 ir bit? I don’t have the IR bit but maybe I can use the long LED bit with an IR LED?

Frank

This is the 02 long led diagram:

And this is the o7 IR led diagram:

I think (not proven) that the long led cannot send pulses, but it could be tested (which pulses to use ? )

Hi Frank @cfsl,

I checked both IR led o7 and the long led o2 to see if they can send pulses. I tested with audio pulses,
I used the following circuit as a receiver: battery-power-light sensor-speaker.
To send signals I used 4 different setups:
battery-power-oscillator-IR led and
battery-power-oscillator -long led and
battery-power-mp3 player-IR led and
battery-power-mp3 player-long led.

In all cases the signal could be heard loud and clear, so I think both led versions (IR and long led) can send audio pulses. And yes, replacing the white long led with an IR led on the o2 bit will work also I think. :grinning:

Here you can find some information about using the IRRemote library with the Arduino bit to send pulses:
But these pulses are in a much higher frequency range, so I am not sure if it will work…


Just try if it works…

Hi Alex,

Interesting experiment! In the project I mentioned, @rbender uses the IR bit to control a LEGO train, so it can definitely send pulses quickly enough to act as an IR remote.

I’m asking about using the o2 bit with an IR led because it would give me an inexpensive way to use the arduino bit as a remote control. Littlebits prices are quite high in Europe as you know and it would be a good incentive for me to do more on the hardware side (I’m a software guy so my comfort zone is writing a program instead of soldering).

Based on your input, the combo o2 bit + IR led might work, though the o2 may not provide sufficient current for the IR led.

Best way for me to find out is to try. Suggestions for a good electronics store delivering to Belgium are welcome :smile: The one I know about which also sells littlebits is kiwi electronics. Do these kind of stores typically have discounts for the holiday season?

Frank