0

Pro Trinket 5V and IRLib2
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Pro Trinket 5V and IRLib2

by lawsonmcw on Thu Jun 21, 2018 10:45 pm

I followed the tutorial here https://learn.adafruit.com/using-an-inf ... are-needed using an Arduino Uno to receive an IR code, flashing the LED on pin 13 when a code was received and then setting a digital output pin to HIGH on the appropriate code. The tutorial was great and I got it up and running with minimal difficulty. Once that was working, I ordered a Pro Trinket 5V to make the project permanent based on the description that most sketches should run unchanged on the Trinket. Unfortunately that doesn't seem to be the case for me.

I was wondering if anybody has used IRLib2 successfully with the Pro Trinket before? Perhaps there is some incompatibility I'm not aware of? If I splice the original Arduino Uno project into the soldered Trinket/IR project it works fine, receives the IR code (so I didn't burn that out) and powers up the Trinket (so my connections there would seem to be good). I see 5 volts across the supply and ground of the IR receiver. So that just leaves the output. I have tried three different pins, 8, 6, and even A0/14 on the other side of the board (and of course changed the code to the appropriate pin and re-uploaded), but nothing has worked so far. Which leads me to believe that perhaps the problem could be with IRLib2 on the Trinket? Any thoughts on troubleshooting would be greatly appreciated. I'm out of ideas! The lightly modified code I'm using based on the tutorial is below. Thank you!
Regards,
Lawson M.

Code: Select all | TOGGLE FULL SIZE
#include "IRLibAll.h"

//Create a receiver object to listen on pin 8
IRrecvPCI myReceiver(8);

//Create a decoder object
IRdecode myDecoder;
int POWER = 4;
int LED = 13;

void setup() {
  //Serial.begin(9600);
  //delay(2000); while (!Serial); //delay for Leonardo
  myReceiver.enableIRIn(); // Start the receiver
  //Serial.println(F("Ready to receive IR signals"));
  pinMode(POWER, OUTPUT);
  pinMode(LED, OUTPUT);
}

void loop() {
  //Continue looping until you get a complete signal received
   
  if (myReceiver.getResults()) {
    myDecoder.decode();           //Decode it
    unsigned long irVal = myDecoder.value;
    //Serial.println(irVal);
    //myDecoder.dumpResults(true);  //Now print results. Use false for less detail

    //flash LED to let the world know we received and IR code
    digitalWrite(LED, HIGH);
    delay(25);
    digitalWrite(LED, LOW);
   
    if (irVal == 3631366335)
    {
      digitalWrite(POWER, HIGH);
    }
    else if (irVal == 3631382655)
    {
      digitalWrite(POWER, LOW);
    }
   
    myReceiver.enableIRIn();      //Restart receiver
  }
}

lawsonmcw
 
Posts: 3
Joined: Thu Jun 21, 2018 9:45 pm

Re: Pro Trinket 5V and IRLib2

by adafruit_support_mike on Fri Jun 22, 2018 1:01 am

The Pro Trinket uses the same microcontroller as the Uno, so the code should work.

Post a photo showing your hardware and connections when the IR sensor is connected to the Pro Trinket and we'll take a look. 800x600 images usually work best.

adafruit_support_mike
 
Posts: 51313
Joined: Thu Feb 11, 2010 2:51 pm

Re: Pro Trinket 5V and IRLib2

by lawsonmcw on Sun Jun 24, 2018 7:16 pm

I took everything apart to simplify as much as possible for photos but now it doesn't work even in the breadboard although it did for a minute tonight on the Uno. So I must have fried the IR receiver(s) somehow. The TSOP382/384 (I had one of each) must be way more sensitive than I appreciated. I'll get another batch and try again and report back. Thank you for your help.

Best regards,
Lawson

lawsonmcw
 
Posts: 3
Joined: Thu Jun 21, 2018 9:45 pm

Re: Pro Trinket 5V and IRLib2

by lawsonmcw on Tue Jul 10, 2018 10:12 pm

Posting a follow-up in case this may help someone else down the road. It turns out there was nothing wrong whatsoever with the IR receiver or my soldering (as ugly as it may have been). The original adafruit tutorial https://learn.adafruit.com/using-an-infrared-library/hardware-needed on using IRLib2 with Arduino had the IR output going to pin 2 on the Arduino. But the Pro Trinket doesn't expose a digital pin 2. So I looked at the pinout and saw that pin 8 was a digital input with "nothing particularly special about this GPIO pin" which seemed to be the perfect candidate. But for whatever reason I could never get IRLib2 to work using pin 8 either on the Pro Trinket or it turns out even the Arduino Uno. I'm a total newbie so there could be something special about pin 8 versus pin 2 but I'm not aware of any difference. So it may be a quirk with IRLib2. Bottom line is the IRLib2 code worked fine on an Arduino Uno on pin 2 or 3 but not 8. I ended up using pin 3 on the Pro Trinket and it's working brilliantly. I'm using it to listen for power on/off commands and trigger a power amplifier to turn on, eliminating an old preamp that was doing little more than switching the amp on and generating a lot of heat. Hope this helps someone else having trouble with IRLib2.

Lawson

lawsonmcw
 
Posts: 3
Joined: Thu Jun 21, 2018 9:45 pm

Re: Pro Trinket 5V and IRLib2

by adafruit_support_mike on Thu Jul 12, 2018 4:06 am

Glad to hear you got things working!

Pins 2 and 3 support more kinds of interrupts than the rest of the GPIO pins. Apparently something the IRlib2 uses the edge-based or level-based interrupts.

adafruit_support_mike
 
Posts: 51313
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.