tronixstuff IR Receiver tutorial

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
lsfanboi
Posts: 7
Joined: Fri Aug 02, 2013 12:28 am

tronixstuff IR Receiver tutorial

Post by lsfanboi » Fri Aug 02, 2013 12:56 am

Hi,

Not sure if this is the right place to ask but I was hoping someone would help me out with trying to get the IR Receiver posted on tronixstuff's blog http://tronixstuff.com/2011/03/30/tutor ... d-control/.

I haven't been using an arduino since the duemilanove and I just bought my first leostick this week at the city Jaycar store. I presume it is v2.0 from the get started guide according to the blinking lights and am using arduino IDE 1.0.5. Also I have made the changes as suggested in the blog to use Arduino.h instead of WProgram.h in the header file but I still get the following compile error.

Code: Select all

Arduino_1.0.5\libraries\IRremote\IRremote.cpp: In member function 'void IRsend::mark(int)':
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:172: error: 'TCCR2A' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:172: error: 'COM2B1' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp: In member function 'void IRsend::space(int)':
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:180: error: 'TCCR2A' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:180: error: 'COM2B1' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp: In member function 'void IRsend::enableIROut(int)':
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:207: error: 'TCCR2A' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:207: error: 'WGM20' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:208: error: 'TCCR2B' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:208: error: 'WGM22' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:208: error: 'CS20' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:211: error: 'OCR2A' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:212: error: 'OCR2B' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp: In member function 'void IRrecv::enableIRIn()':
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:224: error: 'TCCR2A' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:229: error: 'TCCR2B' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:229: error: 'CS22' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:230: error: 'CS21' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:231: error: 'CS20' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:236: error: 'TCNT2' was not declared in this scope
Arduino_1.0.5\libraries\IRremote\IRremote.cpp: In function 'void TIMER2_OVF_vect()':
Arduino_1.0.5\libraries\IRremote\IRremote.cpp:266: error: 'TCNT2' was not declared in this scope
This error looks to me like it's more to do with the new chip in the leo* than the leostick so not sure if it should be in another forum. From what I've read and tried to google the atmega32u4 does not have a timer2. I've also been trying to get up to speed on the AVR timers so I'm new to this so not sure if anyone can help, has fixed this issue or point me in the right direction.

Any help would be appreciated thanks. :)

lsfanboi
Posts: 7
Joined: Fri Aug 02, 2013 12:28 am

Re: tronixstuff IR Receiver tutorial

Post by lsfanboi » Fri Aug 02, 2013 11:57 pm

I've been reading the atmega32u4 documentation and there doesn't appear to be another 8bit timer to redirect the code hence by changing to timer 3 and modifying the CLK variable for a 16bit timer I managed to get it to compile and work with the IRReceiver component. Haven't tried the IRSend function but for my purposes I only needed the receiver to work. Hopefully this helps someone else trying to get this to work.

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: tronixstuff IR Receiver tutorial

Post by andrew » Sun Aug 04, 2013 11:40 pm

Ken's IR library is only for boards with ATmega328 so doesn't work on Arduino Leonardo nor the Freetronics LeoStick.

Try this modified version - http://tech.cyborg5.com/irlib/

lsfanboi
Posts: 7
Joined: Fri Aug 02, 2013 12:28 am

Re: tronixstuff IR Receiver tutorial

Post by lsfanboi » Mon Aug 05, 2013 3:08 am

Cool will try as well. Thanks for your help.

drake250
Posts: 19
Joined: Mon May 28, 2012 1:17 pm
Location: Adelaide

Re: tronixstuff IR Receiver tutorial

Post by drake250 » Tue Aug 06, 2013 12:54 pm

johnb wrote:Try this modified version - http://tech.cyborg5.com/irlib/
Thanks for the link - worked straight out of the box on my v2 Leostick, receive and transmit!
I'm using the default pins - receiver on 11 and IR LED on 9.

This could be a really cheap way to network Leosticks - the receiver and LED were salvaged parts.

p.s. If you want to transmit and receive, you have to restart the receive timer after transmitting, since the transmit PWM uses the same timer as the receiver.
i.e.

Code: Select all

My_Sender.send(NEC, 0x123456, 32);
My_Receiver.enableIRIn(); //restarts timer, .resume() only clears decoded data

Post Reply