├── Pronto ├── Pronto.cpp ├── Pronto.h ├── README.md └── examples │ ├── ProntoCodesSentOverSerial │ └── ProntoCodesSentOverSerial.ino │ ├── SendHardcodedPronto │ └── SendHardcodedPronto.ino │ ├── SendProntoHexWithoutLibraryHard │ └── SendProntoHexWithoutLibraryHard.ino │ └── SendProntoHexWithoutLibrarySerial │ └── SendProntoHexWithoutLibrarySerial.ino ├── README.md └── send_pronto_hex.ino /Pronto/Pronto.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Pronto.cpp - Library for sending Pronto hex infrared codes. 3 | */ 4 | 5 | #include "Arduino.h" 6 | #include "Pronto.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define IR_TIMER1_OVF_vect TIMER1_OVF_vect //Definition for ISR Timer1 15 | #define IR_TCCRnA TCCR1A 16 | #define IR_TCCRnB TCCR1B 17 | // #define IR_PIN PINB 18 | // #define IR_DDR DDRB 19 | // #define IR_BV _BV(1) 20 | #define IR_TCNTn TCNT1 21 | #define IR_TIFRn TIFR1 22 | #define IR_TIMSKn TIMSK1 23 | #define IR_TOIEn TOIE1 24 | #define IR_ICRn ICR1 25 | #define IR_OCRn OCR1A 26 | #define IR_COMn0 COM1A0 27 | #define IR_COMn1 COM1A1 28 | 29 | #define PRONTO_IR_SOURCE 0 // Pronto code byte 0 30 | #define PRONTO_FREQ_CODE 1 // Pronto code byte 1 31 | #define PRONTO_SEQUENCE1_LENGTH 2 // Pronto code byte 2 32 | #define PRONTO_SEQUENCE2_LENGTH 3 // Pronto code byte 3 33 | #define PRONTO_CODE_START 4 // Pronto code byte 4 34 | 35 | 36 | static Pronto pronto(9); // has to be here for the ISR to work properly 37 | 38 | static const uint16_t *ir_code = NULL; 39 | static uint16_t ir_cycle_count = 0; 40 | static uint32_t ir_total_cycle_count = 0; 41 | static uint8_t ir_seq_index = 0; 42 | static uint8_t ir_led_state = 0; 43 | 44 | Pronto::Pronto(int pin){ pinMode(pin, OUTPUT); _pin = pin; } 45 | 46 | void Pronto::ir_on() { IR_TCCRnA |= (1 << IR_COMn1) + (1 << IR_COMn0); ir_led_state = 1; } 47 | 48 | void Pronto::ir_off() { IR_TCCRnA &= ((~(1 << IR_COMn1)) & (~(1 << IR_COMn0)) ); ir_led_state = 0; } 49 | 50 | void Pronto::ir_toggle() { if (ir_led_state) { ir_off(); } else { ir_on(); } } 51 | 52 | void Pronto::ir_start(uint16_t *code) { 53 | ir_code = code; 54 | // IR_PORT &= ~IR_BV; // Turn output off (atmega328 only) 55 | // IR_DDR |= IR_BV; // Set it as output (atmega328 only) 56 | digitalWrite(_pin, LOW); // Turn output off 57 | pinMode(_pin, OUTPUT); // Set it as output 58 | IR_TCCRnA = 0x00; // Reset the pwm 59 | IR_TCCRnB = 0x00; 60 | uint16_t top = ( (F_CPU / 1000000.0) * code[PRONTO_FREQ_CODE] * 0.241246 ) - 1; 61 | IR_ICRn = top; 62 | IR_OCRn = top >> 1; 63 | IR_TCCRnA = (1 << WGM11); 64 | IR_TCCRnB = (1 << WGM13) | (1 << WGM12); 65 | IR_TCNTn = 0x0000; 66 | IR_TIFRn = 0x00; 67 | IR_TIMSKn = 1 << IR_TOIEn; 68 | ir_seq_index = PRONTO_CODE_START; 69 | ir_cycle_count = 0; 70 | ir_on(); 71 | IR_TCCRnB |= (1 << CS10); 72 | } 73 | 74 | #define TOTAL_CYCLES 40000 75 | // Turns off after this number of cycles. About 1 second 76 | // FIXME: Turn off after having sent <---- Should be able to do this one easily now. since it doesn't have to be done inside of ISR 77 | 78 | #if defined(IR_TIMER1_OVF_vect) //makes sure definition is in place 79 | ISR(IR_TIMER1_OVF_vect) { pronto.handleInterrupt(); } //here is the cooky part 80 | #endif 81 | 82 | //and this is what was inside of ISR before. so you can see how the call is made through a var to launch the function. 83 | //and the var is the Pronto pronto(9) you also have to class define this bad larry. in Pronto.h under Public. 84 | //because ISR acts like a global var. and all of the Variables inside of the class function have to be static. 85 | //or should be to make sure this thing is going to communicate propery. 86 | void Pronto::handleInterrupt(){ 87 | uint16_t sequenceIndexEnd; 88 | uint16_t repeatSequenceIndexStart; 89 | ir_total_cycle_count++; 90 | ir_cycle_count++; 91 | if (ir_cycle_count == ir_code[ir_seq_index]) { 92 | ir_toggle(); 93 | ir_cycle_count = 0; 94 | ir_seq_index++; 95 | sequenceIndexEnd = PRONTO_CODE_START + (ir_code[PRONTO_SEQUENCE1_LENGTH] << 1) + (ir_code[PRONTO_SEQUENCE2_LENGTH] << 1); 96 | repeatSequenceIndexStart = PRONTO_CODE_START + (ir_code[PRONTO_SEQUENCE1_LENGTH] << 1); 97 | if (ir_seq_index >= sequenceIndexEnd ) { 98 | ir_seq_index = repeatSequenceIndexStart; 99 | if (ir_total_cycle_count > TOTAL_CYCLES) { 100 | ir_off(); 101 | TCCR1B &= ~(1< 24 | 25 | 26 | 27 | Pronto pronto(9); 28 | 29 | const uint16_t inputLength = 512; 30 | 31 | void setup() { 32 | Serial.begin(9600); 33 | while (Serial.available()); 34 | Serial.print("Hello World!\r\n enter \"SEND\" and the Pronto Code.\r\n"); 35 | Serial.print("0000 spaces between the Pronto Hex\r\n"); 36 | Serial.print("no commas and no trailing spaces\r\n"); 37 | Serial.print("This is a working Hex so you can copy and paste it.\r\n"); 38 | //This is one of thoes very ugly Samsung Smart tv power codes. I think it is 42 bit at 37.9khz 39 | //this is one very long array 78 total cells my sggestion would be to run it through serial 40 | //or script in loading the Pronto Codes from a file. This would just chew up to much memory. there are almost 200 41 | //Pronto Codes like this for a Samsung TV My use if for power on only. all the rest of the commands are wifi or even the EXLINK Port 42 | //that is rs-232 43 | // Not working yet Serial.println("Example: SEND 0x0 0x6D 0x22 0x3 0xA9 0xA8 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x3F 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x15 0x40 0x15 0x15 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x3F 0x15 0x702 0xA9 0xA8 0x15 0x15 0x15 0xE6E"); 44 | Serial.println("Example: SEND 0000 006d 0022 0003 00a9 00a8 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 003f 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 003f 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0015 0040 0015 0015 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 003f 0015 0702 00a9 00a8 0015 0015 0015 0e6e"); 45 | } 46 | 47 | void loop() { 48 | if ( Serial.available() > 0 ) { 49 | static char input[inputLength]; 50 | static uint16_t i; 51 | char c = Serial.read(); 52 | if ( c != '\r' && c != '\n' && i < inputLength-1) 53 | input[i++] = c; 54 | else { 55 | input[i] = '\0'; 56 | i = 0; 57 | uint16_t array[80]; 58 | uint16_t j = 0; 59 | if ( !strncmp(input, "SEND", 4) ) { 60 | char* p = input+4; 61 | while ( (p = strchr(p, ' ')) != NULL ) 62 | array[j++] = strtol(p, &p, 16); 63 | pronto.ir_start(array); 64 | Serial.print("SENT "); 65 | for ( uint8_t i = 0; i < j; i++ ) { 66 | Serial.print ("0x"); 67 | Serial.print (array[i], HEX); 68 | Serial.print(" "); 69 | } 70 | Serial.println(); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Pronto/examples/SendHardcodedPronto/SendHardcodedPronto.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send Pronto Hex via an IR LED connected to Arduino Pin D9. 3 | 4 | Store Pronto Code in uint16_t in either 0x00 or 0000 format commas between each HEX 5 | 6 | Based on IR_Player_ProntoCode.c by Stephen Ong 7 | https://github.com/stephenong/Arduino-IR-Remote-Control-Player 8 | This work is licenced under the Creative Commons Attribution-NonCommercial 9 | 3.0 Unported License. To view a copy of this licence, visit 10 | http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative 11 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 12 | http://creativecommons.org/licenses/by-nc/3.0/ 13 | */ 14 | #include 15 | 16 | 17 | 18 | Pronto pronto(9); 19 | 20 | uint16_t up[78] = { 0x0, 0x6D, 0x22, 0x3, 0xA9, 0xA8, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x3F, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x40, 0x15, 0x15, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x3F, 0x15, 0x702, 0xA9, 0xA8, 0x15, 0x15, 0x15, 0xE6E }; 21 | 22 | void setup() { 23 | Serial.begin(115200); 24 | while (Serial.available()); 25 | Serial.print("Hello World!\r\n enter \"SEND\" to send IR\r\n"); 26 | } 27 | 28 | void loop() { 29 | if (Serial.available() > 0 ) { 30 | String inString = Serial.readString(); 31 | if (inString.startsWith("SEND")) { 32 | int j = 78; 33 | pronto.ir_start(up); 34 | Serial.print("SENT: "); 35 | for ( int i = 0; i < j; i++ ) { 36 | Serial.print ("0x"); 37 | Serial.print (up[i], HEX); 38 | Serial.print(" "); 39 | } 40 | Serial.print("\r\n"); 41 | } 42 | } 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /Pronto/examples/SendProntoHexWithoutLibraryHard/SendProntoHexWithoutLibraryHard.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send Pronto Hex via an IR LED connected to Arduino Pin D9. 3 | 4 | Store Pronto Code in uint16_t in either 0x00 or 0000 format commas between each HEX 5 | 6 | Based on IR_Player_ProntoCode.c by Stephen Ong 7 | https://github.com/stephenong/Arduino-IR-Remote-Control-Player 8 | This work is licenced under the Creative Commons Attribution-NonCommercial 9 | 3.0 Unported License. To view a copy of this licence, visit 10 | http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative 11 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 12 | http://creativecommons.org/licenses/by-nc/3.0/ 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #define IR_PORT PORTB 21 | // #define IR_PIN PINB 22 | // #define IR_DDR DDRB 23 | // #define IR_BV _BV(1) 24 | #define IR_OCR OCR1A 25 | #define IR_TCCRnA TCCR1A 26 | #define IR_TCCRnB TCCR1B 27 | #define IR_TCNTn TCNT1 28 | #define IR_TIFRn TIFR1 29 | #define IR_TIMSKn TIMSK1 30 | #define IR_TOIEn TOIE1 31 | #define IR_ICRn ICR1 32 | #define IR_OCRn OCR1A 33 | #define IR_COMn0 COM1A0 34 | #define IR_COMn1 COM1A1 35 | #define PRONTO_IR_SOURCE 0 // Pronto code byte 0 36 | #define PRONTO_FREQ_CODE 1 // Pronto code byte 1 37 | #define PRONTO_SEQUENCE1_LENGTH 2 // Pronto code byte 2 38 | #define PRONTO_SEQUENCE2_LENGTH 3 // Pronto code byte 3 39 | #define PRONTO_CODE_START 4 // Pronto code byte 4 40 | 41 | int _pin = 9; //change number to change the pinMode 42 | static const uint16_t *ir_code = NULL; 43 | static uint16_t ir_cycle_count = 0; 44 | static uint32_t ir_total_cycle_count = 0; 45 | static uint8_t ir_seq_index = 0; 46 | static uint8_t ir_led_state = 0; 47 | 48 | void ir_on() 49 | { 50 | IR_TCCRnA |= (1<> 1; 82 | IR_TCCRnA = (1<= sequenceIndexEnd ) { 114 | ir_seq_index = repeatSequenceIndexStart; 115 | 116 | if(ir_total_cycle_count>TOTAL_CYCLES) { 117 | ir_off(); 118 | TCCR1B &= ~(1< 0 ) { 143 | String inString = Serial.readString(); 144 | if (inString.startsWith("SEND")) { 145 | int j = 78; 146 | ir_start(up); 147 | Serial.print("SENT: "); 148 | for ( int i = 0; i < j; i++ ) { 149 | Serial.print ("0x"); 150 | Serial.print (up[i], HEX); 151 | Serial.print(" "); 152 | } 153 | Serial.print("\r\n"); 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /Pronto/examples/SendProntoHexWithoutLibrarySerial/SendProntoHexWithoutLibrarySerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send Pronto Hex via an IR LED connected to Arduino Pin D9. 3 | Make sure you do not send a blank (" ") as the last character. 4 | Send the following command over the serial line: 5 | 6 | Sony12, device = 1, obc = 47 7 | 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 8 | 9 | or 10 | 11 | # RC5, device = 11, obc = 64 12 | SEND 0000 0073 0000 000B 0040 0020 0020 0020 0020 0040 0040 0040 0020 0020 0040 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0CC8 13 | 14 | Based on IR_Player_ProntoCode.c by Stephen Ong 15 | https://github.com/stephenong/Arduino-IR-Remote-Control-Player 16 | This work is licenced under the Creative Commons Attribution-NonCommercial 17 | 3.0 Unported License. To view a copy of this licence, visit 18 | http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative 19 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 20 | http://creativecommons.org/licenses/by-nc/3.0/ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #define IR_PORT PORTB 29 | // #define IR_PIN PINB 30 | // #define IR_DDR DDRB 31 | // #define IR_BV _BV(1) 32 | #define IR_OCR OCR1A 33 | #define IR_TCCRnA TCCR1A 34 | #define IR_TCCRnB TCCR1B 35 | #define IR_TCNTn TCNT1 36 | #define IR_TIFRn TIFR1 37 | #define IR_TIMSKn TIMSK1 38 | #define IR_TOIEn TOIE1 39 | #define IR_ICRn ICR1 40 | #define IR_OCRn OCR1A 41 | #define IR_COMn0 COM1A0 42 | #define IR_COMn1 COM1A1 43 | #define PRONTO_IR_SOURCE 0 // Pronto code byte 0 44 | #define PRONTO_FREQ_CODE 1 // Pronto code byte 1 45 | #define PRONTO_SEQUENCE1_LENGTH 2 // Pronto code byte 2 46 | #define PRONTO_SEQUENCE2_LENGTH 3 // Pronto code byte 3 47 | #define PRONTO_CODE_START 4 // Pronto code byte 4 48 | 49 | static const uint16_t *ir_code = NULL; 50 | static uint16_t ir_cycle_count = 0; 51 | static uint32_t ir_total_cycle_count = 0; 52 | static uint8_t ir_seq_index = 0; 53 | static uint8_t ir_led_state = 0; 54 | 55 | void ir_on() 56 | { 57 | IR_TCCRnA |= (1<> 1; 89 | IR_TCCRnA = (1<= sequenceIndexEnd ) { 121 | ir_seq_index = repeatSequenceIndexStart; 122 | 123 | if(ir_total_cycle_count>TOTAL_CYCLES) { 124 | ir_off(); 125 | TCCR1B &= ~(1< 0 ) { 157 | static char input[inputLength]; 158 | static uint16_t i; 159 | char c = Serial.read(); 160 | if ( c != '\r' && c != '\n' && i < inputLength-1) 161 | input[i++] = c; 162 | else { 163 | input[i] = '\0'; 164 | i = 0; 165 | uint16_t array[80]; 166 | uint16_t j = 0; 167 | if ( !strncmp(input, "SEND", 4) ) { 168 | char* p = input+4; 169 | while ( (p = strchr(p, ' ')) != NULL ) 170 | array[j++] = strtol(p, &p, 16); 171 | ir_start(array); 172 | Serial.print("SENT "); 173 | for ( uint8_t i = 0; i < j; i++ ) { 174 | Serial.print ("0x"); 175 | Serial.print (array[i], HEX); 176 | Serial.print(" "); 177 | } 178 | Serial.println(); 179 | } 180 | } 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Arduino Pronto Hex Sender 2 | ========================= 3 | 4 | Arduino sketch to send Pronto Hex commands with an infrared LED attached to pin D9. 5 | 6 | To send Sony12, device = 1, obc = 47, send the following command over the serial line withg 9600 N 1: 7 |
 8 | 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
 9 | 
10 | 11 | You can find out these commands from community maintained databases such as http://irdb.tk 12 | 13 | Make sure you send a newline character at the end of the line. 14 | -------------------------------------------------------------------------------- /send_pronto_hex.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send Pronto Hex via an IR LED connected to Arduino Pin D9. 3 | Make sure you do not send a blank (" ") as the last character. 4 | Send the following command over the serial line: 5 | 6 | Sony12, device = 1, obc = 47 7 | 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 8 | 9 | or 10 | 11 | # RC5, device = 11, obc = 64 12 | SEND 0000 0073 0000 000B 0040 0020 0020 0020 0020 0040 0040 0040 0020 0020 0040 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0CC8 13 | 14 | Based on IR_Player_ProntoCode.c by Stephen Ong 15 | https://github.com/stephenong/Arduino-IR-Remote-Control-Player 16 | 17 | This work is licenced under the Creative Commons Attribution-NonCommercial 18 | 3.0 Unported License. To view a copy of this licence, visit 19 | http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative 20 | Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA. 21 | 22 | http://creativecommons.org/licenses/by-nc/3.0/ 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #define IR_PORT PORTB 31 | // #define IR_PIN PINB 32 | // #define IR_DDR DDRB 33 | // #define IR_BV _BV(1) 34 | #define IR_OCR OCR1A 35 | #define IR_TCCRnA TCCR1A 36 | #define IR_TCCRnB TCCR1B 37 | #define IR_TCNTn TCNT1 38 | #define IR_TIFRn TIFR1 39 | #define IR_TIMSKn TIMSK1 40 | #define IR_TOIEn TOIE1 41 | #define IR_ICRn ICR1 42 | #define IR_OCRn OCR1A 43 | #define IR_COMn0 COM1A0 44 | #define IR_COMn1 COM1A1 45 | #define PRONTO_IR_SOURCE 0 // Pronto code byte 0 46 | #define PRONTO_FREQ_CODE 1 // Pronto code byte 1 47 | #define PRONTO_SEQUENCE1_LENGTH 2 // Pronto code byte 2 48 | #define PRONTO_SEQUENCE2_LENGTH 3 // Pronto code byte 3 49 | #define PRONTO_CODE_START 4 // Pronto code byte 4 50 | 51 | static const uint16_t *ir_code = NULL; 52 | static uint16_t ir_cycle_count = 0; 53 | static uint32_t ir_total_cycle_count = 0; 54 | static uint8_t ir_seq_index = 0; 55 | static uint8_t ir_led_state = 0; 56 | 57 | void ir_on() 58 | { 59 | IR_TCCRnA |= (1<> 1; 91 | IR_TCCRnA = (1<= sequenceIndexEnd ) { 123 | ir_seq_index = repeatSequenceIndexStart; 124 | 125 | if(ir_total_cycle_count>TOTAL_CYCLES) { 126 | ir_off(); 127 | TCCR1B &= ~(1< 0 ) 149 | { 150 | static char input[inputLength]; 151 | static uint16_t i; 152 | char c = Serial.read(); 153 | 154 | if ( c != '\r' && c != '\n' && i < inputLength-1) 155 | input[i++] = c; 156 | 157 | else 158 | { 159 | input[i] = '\0'; 160 | i = 0; 161 | 162 | uint16_t array[80]; 163 | uint16_t j = 0; 164 | 165 | if ( !strncmp(input, "SEND", 4) ) 166 | { 167 | char* p = input+4; 168 | 169 | while ( (p = strchr(p, ' ')) != NULL ) 170 | array[j++] = strtol(p, &p, 16); 171 | 172 | ir_start(array); 173 | Serial.print("SENT "); 174 | for ( uint8_t i = 0; i < j; i++ ) 175 | { 176 | Serial.print ("0x"); 177 | Serial.print (array[i], HEX); 178 | Serial.print(" "); 179 | } 180 | 181 | 182 | Serial.println(); 183 | } 184 | } 185 | } 186 | } 187 | --------------------------------------------------------------------------------