I used the testInfraredRemote.ino to verify a 40 button IR remote for my RGB LED's could be read and properly decoded by Nybble's IR receiver. The serial console in Arduino showed all the codes received for all 40 buttons. A few overlapped with known Nybble hex codes, most were new. I am trying to understand the Nybble.ino so that I can substitute my new IR codes for the commands listed in the sketch.
I have two main questions. First what is the purpose of the "#ifdef DEVELOPER" statement and how is it controlled. Second, I see two sets of Case statements defining which ir code is assigned to which instinct. If I am to overwite Nybbles default ir codes with my own, which set of case statements is the correct one to modify? I have experimented with changing the first three statements in each section of the #ifdef DEVELOPER #else #endif (for "Sit", "d" and "hi") but after uploading to the board, I see no response from my newly mapped keys on new remote.
What am I missing?
Chris
Rongzhong Li,
Your first response was all I really needed to understand how that code section should work. I was quickly able to map out all the new hex codes and now have a 44 key IR remote working on my Nybble! I mapped all the basic instincts that you originally used and still have over half of the remote free for additional behaviors!
This is the remote I found on Amazon for $5.59 (https://www.amazon.com/gp/product/B00AF5YOK2/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1)
These are the mappings and a crude representation of how I used the lower keys to actuate the original instincts.
Finally, here is my revised code section. I will simply add new case statements as I choose more instincts to map to my unused buttons.
IRrecv irrecv(IR_RECIEVER); // create instance of 'irrecv' decode_results results; // create instance of 'decode_results' String translateIR() // takes action based on IR code received // describing Remote IR codes. { switch (results.value) { //IR signal key on IR remote //abbreviation of gaits //gait/posture names #ifdef DEVELOPER case 0xFFF00F: PTLF(" CH-"); return (F("sit")); case 0xFFE01F: PTLF(" CH"); return (F("d")); //shutdown all servos case 0xFFD02F: PTLF(" CH+"); return (F("hi")); //greetings case 0xFFA05F: PTLF(" |<<"); return (F("buttUp")); //butt up case 0xFFC837: PTLF(" >>|"); return (F("balance")); //neutral standing case 0xFF20DF: PTLF(" >||"); return (F("str")); //stretch case 0xFFE817: PTLF(" -"); return (F("pee")); // case 0xFFA857: PTLF(" +"); return (F("tr")); //trot case 0xFF609F: PTLF(" EQ"); return (F("pu")); // push up case 0xFF08F7: PTLF(" 0"); return (F("wkL")); //walk left case 0xFF8877: PTLF(" 100+"); return (F("wk")); //walk case 0xFF48B7: PTLF(" 200+"); return (F("wkR")); //walk right case 0xFF30CF: PTLF(" 1"); return (F("crL")); //crawl left case 0xFFB04F: PTLF(" 2"); return (F("cr")); //crawl fast case 0xFF708F: PTLF(" 3"); return (F("crR")); //crawl right case 0xFF10EF: PTLF(" 4"); return (F("bkL")); // back left case 0xFF906F: PTLF(" 5"); return (F("bk")); //back case 0xFF50AF: PTLF(" 6"); return (F("bkR")); //back right case 0xFF42BD: PTLF(" 7"); return (F("tb")); //turbo case 0xFF4AB5: PTLF(" 8"); return (F("zero")); //customed skill case 0xFFD827: PTLF(" 9"); return (F("rc")); //recover (turtle roll ) #else case 0xFFF00F: return (F("sit")); case 0xFFE01F: return (F("d")); //shutdown all servos case 0xFFD02F: return (F("hi")); //greetings case 0xFFA05F: return (F("buttUp")); //butt up case 0xFFC837: return (F("balance")); //neutral standing case 0xFF20DF: return (F("str")); //stretch case 0xFFE817: return (F("pee")); // case 0xFFA857: return (F("tr")); //trot case 0xFF609F: return (F("pu")); // push up case 0xFF08F7: return (F("wkL")); //walk left case 0xFF8877: return (F("wk")); //walk case 0xFF48B7: return (F("wkR")); //walk right case 0xFF30CF: return (F("crL")); //crawl left case 0xFFB04F: return (F("cr")); //crawl fast case 0xFF708F: return (F("crR")); //crawl right case 0xFF10EF: return (F("bkL")); // back left case 0xFF906F: return (F("bk")); //back case 0xFF50AF: return (F("bkR")); //back right case 0xFF42BD: return (F("tb")); //turbo case 0xFF4AB5: return (F("zero")); //customed skill case 0xFFD827: return (F("rc")); //recover (turtle roll ) #endif case 0xFFFFFFFF: return (""); //Serial.println(" REPEAT"); default: { Serial.println(results.value, HEX); } return (""); //Serial.println("null"); }// End Case //delay(100); // Do not get immediate repeat //no need because the main loop is slow // The control could be organized in another way, such as: // forward/backward to change the gaits corresponding to different speeds. // left/right key for turning left and right // number keys for different postures or behaviors }