//------------------------------------------------------------------------------------------------------------------------- /* * IrDA receive data print program * IRreceive_print01.ino * 2020.5.28 * Original Scketch ATtiny85 IR Remote Control Receiver David Johnson-Davies - www.technoblogy.com - 3rd April 2015 ATtiny85 @ 1 MHz (internal oscillator; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ #include SoftwareSerial mySerial(3, 4); // RX(PB3:Pin2), TX(PB4:Pin3) // LED outputs int LED = 1; // LED indicator PB1(Pin6) volatile int NextBit; volatile unsigned long RecdData; volatile int Rcvflag = 0; volatile int RcvDATA; char HEXprint[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'} ; // Setup ********************************************** void setup() { // Set up LEDs pinMode(LED, OUTPUT); // initialize Serial Port mySerial.begin(9600); delay(500); mySerial.println("Serial connect"); // Set up Timer/Counter0 (assumes 8MHz clock) TCCR0A = 0; // No compare matches TCCR0B = 5<>4 ; // pickup upper 4 bits mySerial.print(HEXprint[Pdata]); // print in HEX Pdata = (RcvDATA & 0x0F); // pickup lower 4 bits mySerial.println(HEXprint[Pdata]); // print in HEX digitalWrite(LED, 1); // indicator LED blink delay(100); digitalWrite(LED, 0); } } // *** Interrupt service routine - called on every falling edge of PB2 *** ISR(INT0_vect) { int Time = TCNT0; int Overflow = TIFR & 1<= 87) && (Time <= 114) && (Overflow == 0)) { RecdData = 0; NextBit = 0; } else if ((Time >= 80) && (Time <= 97) && (Overflow == 0)) ReceivedCode(1); // Data bit } else { if ((Time > 22) || (Overflow != 0)) NextBit = 32; // Invalid - restart else { if (Time > 13) RecdData = RecdData | ((unsigned long) 1<>16 & 0xFF; // Set DATA receivedflag for SerialPrint Rcvflag = 1; }