×

Please see all COVID-19 updates here as some shipments may be delayed due to CDC safety and staffing guidelines. If you have an order or shipping question please refer to our Customer Support page. For technical questions please check out our Forums. Thank you for your continued support.

Member #270232

Member Since: November 28, 2011

Country: United States

  • Hey guys, I modified the code above so it is interrupt driven (rather than busy waiting on a single pin). Hopefully others find this useful too...

    /*A simple interrupt base class to read IR input from the TSOP382 receiver diode -The user can poll "ir.available()" in their loop to see if a new key has been pressed, leaving the Arduino available for other processing

    Jordan Erenrich jordan.erenrich AT gmail.com Oct 4, 2012 */

    define START_BIT 2200 //Start bit threshold (Microseconds)

    define BIN_1 900 //Binary 1 threshold (Microseconds)

    define BIN_0 400 //Binary 0 threshold (Microseconds)

    class IrReader { private: boolean resultAvail;

    int val, prevVal, pin, bitCount, result;
    unsigned long startTime, elapsedTime;
    

    public: IrReader(int pin, int interruptNumber, void(*interruptCallback)( )) { this->pin = pin; pinMode(pin, INPUT);
    prevVal = digitalRead(pin); bitCount = -1; resultAvail = false;

      attachInterrupt(interruptNumber, interruptCallback, CHANGE);      
    }
    
    boolean available() {
      return resultAvail;
    }
    
    int getKey() {
      resultAvail = false;
      return result;
    }
    
    void eval() {
      //Prevent reading a new result if an old result is still pending
      //(Could potentially miss a new key, but at least you won't get a garbage key)
      if (! resultAvail) {
        val = digitalRead(pin);
    
        if (val != prevVal) { //Value has changed
          prevVal = val;
    
          if (val == LOW) { //Falling value
            startTime = micros();
          } else { //Rising value - New Bit
            elapsedTime = micros() - startTime;
    
            if (elapsedTime >= START_BIT) {
              bitCount = 0;
              result = 0;
            } else if (bitCount != -1) {
              bitCount++;
    
              if(elapsedTime >= BIN_1) //Assume that anything shorter is a zero
                result |= (1 
    
  • Hi the product notes ("Supports 64Mb to 2Gig micro-SD memory cards (FAT format)") are inconsistent with the datasheet ("Support 1GB SD card max. or SPI flash 64MB max."). Which is correct?

  • This module doesn't seem to work well in the presence of other Bluetooth units. I was experiencing sporadic disconnections (especially when during high data rates), which disappeared when I turned off the BT keyboard on my computer. Are there any settings one can add to make this module more robust to other BT hardware near it?

  • Hi, did you use a 10ohm resistor or a 50ohm resistor? The electrical integration PDF mentions a 50ohm, but I'm wondering if the PDF had a typo, or maybe you did above? Thanks

No public wish lists :(