/* Send Pronto Hex via Irdroino shield connected to Arduino Pin D9 (make a jumper wire connection between pin 9 and pin 3). Sample usage: SEND 0000 0067 0000 000d 0060 0018 0030 0018 0030 0018 0030 0018 0030 0018 0018 0018 0030 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 03de Based on https://github.com/stephenong/Arduino-IR-Remote-Control-Player */ #include #include #include #include #include #define IR_PORT PORTB #define IR_PIN PINB #define IR_DDR DDRB #define IR_BV _BV(1) #define IR_OCR OCR1A #define IR_TCCRnA TCCR1A #define IR_TCCRnB TCCR1B #define IR_TCNTn TCNT1 #define IR_TIFRn TIFR1 #define IR_TIMSKn TIMSK1 #define IR_TOIEn TOIE1 #define IR_ICRn ICR1 #define IR_OCRn OCR1A #define IR_COMn0 COM1A0 #define IR_COMn1 COM1A1 #define PRONTO_IR_SOURCE 0 // Pronto code byte 0 #define PRONTO_FREQ_CODE 1 // Pronto code byte 1 #define PRONTO_SEQUENCE1_LENGTH 2 // Pronto code byte 2 #define PRONTO_SEQUENCE2_LENGTH 3 // Pronto code byte 3 #define PRONTO_CODE_START 4 // Pronto code byte 4 static const uint16_t *ir_code = NULL; static uint16_t ir_cycle_count = 0; static uint32_t ir_total_cycle_count = 0; static uint8_t ir_seq_index = 0; static uint8_t ir_led_state = 0; void ir_on() { IR_TCCRnA |= (1<> 1; IR_TCCRnA = (1<= sequenceIndexEnd ) { ir_seq_index = repeatSequenceIndexStart; if(ir_total_cycle_count>TOTAL_CYCLES) { ir_off(); TCCR1B &= ~(1< 0 ) { static char input[inputLength]; static uint16_t i; char c = Serial.read(); if ( c != '\r' && c != '\n' && i < inputLength-1) input[i++] = c; else { input[i] = '\0'; i = 0; uint16_t array[80]; uint16_t j = 0; if ( !strncmp(input, "SEND", 4) ) { char* p = input+4; while ( (p = strchr(p, ' ')) != NULL ) array[j++] = strtol(p, &p, 16); ir_start(array); Serial.print("SENT "); for ( uint8_t i = 0; i < j; i++ ) { Serial.print ("0x"); Serial.print (array[i], HEX); Serial.print(" "); } Serial.println(); } } } }