Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRremote.h>
- int RECV_PIN = 11;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- void setup()
- {
- Serial.begin(9600);
- irrecv.enableIRIn(); // Start the receiver
- }
- // Dumps out the decode_results structure.
- // Call this after IRrecv::decode()
- // void * to work around compiler issue
- //void dump(void *v) {
- // decode_results *results = (decode_results *)v
- void dump(decode_results *results) {
- int count = results->rawlen;
- if (results->decode_type == UNKNOWN) {
- Serial.print("Unknown encoding: ");
- }
- else if (results->decode_type == NEC) {
- Serial.print("Decoded NEC: ");
- }
- else if (results->decode_type == SONY) {
- Serial.print("Decoded SONY: ");
- }
- else if (results->decode_type == RC5) {
- Serial.print("Decoded RC5: ");
- }
- else if (results->decode_type == RC6) {
- Serial.print("Decoded RC6: ");
- }
- else if (results->decode_type == SAMSUNG) {
- Serial.print("Decoded SAMSUNG: ");
- }
- else if (results->decode_type == JVC) {
- Serial.print("Decoded JVC: ");
- }
- else if (results->decode_type == PANASONIC) {
- Serial.print("Decoded Panasonic: ");
- }
- //(results->value, HEX);
- switch (result->value) {
- case 16724175:
- Serial.print ("1");
- break;
- case 16718055:
- Serial.print ("2");
- break;
- case 16743045:
- Serial.print ("3");
- break;
- default:
- Serial.print ("hai premuto un tasto che io non riconosco");
- break;
- }
- Serial.print("(");
- Serial.print(results->bits, DEC);
- Serial.println(" bits)");
- Serial.print("#define Something_DEC ");
- Serial.println(results->value, DEC);
- Serial.print("#define Something_HEX ");
- Serial.println(results->value, HEX);
- /* Serial.print("Raw (");
- Serial.print(count, DEC);
- Serial.print("): ");
- for (int i = 0; i < count; i++) {
- if ((i % 2) == 1) {
- Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
- }
- else {
- Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
- }
- Serial.print(" ");
- }*/
- Serial.println("");
- }
- void loop() {
- if (irrecv.decode(&results)) {
- dump(&results);
- irrecv.resume(); // Receive the next value
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement