0

Sample code for Remote control dashboard block?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Sample code for Remote control dashboard block?

by kcl1s on Fri Jan 05, 2018 6:13 pm

Hi,
Just wondering if there is some sample code for using the remote control keypad dashboard block?

Keith

kcl1s
 
Posts: 539
Joined: Tue Aug 30, 2016 12:06 pm

Re: Sample code for Remote control dashboard block?

by abachman on Mon Jan 08, 2018 1:20 pm

Hi kcl1s!


We do not have example code at this time, but if you drop a stream block on your dashboard next to the remote control and connect it to the same feed you can see that it's just sending numbers when the buttons are pressed. Starting at the top left, the values are:
Code: Select all | TOGGLE FULL SIZE
 0   1   2

 4   5   6

 8   9  10

12  13  14

16  17  18

20  21  22

24  25  26


It's a very simplistic block right now, but it's intended to mimic the values sent by the Mini Remote Control we sell and which was included in ADABOX 004.

So, no example code, but a simple subscription script that checks the received value could react as needed. For example:
Code: Select all | TOGGLE FULL SIZE
void handleMessage(AdafruitIO_Data *data) {
 
  Serial.print("received <- ");
  Serial.println(data->value());

  switch(data->toInt()) {
    case 0:
      Serial.println("VOL-");
      break;
    case 1:
      Serial.println(">");
      break;
    case 2:
      Serial.println("VOL+");
      break;
    // etc...
  }
}



- adam

abachman
 
Posts: 131
Joined: Mon Feb 01, 2010 12:48 pm

Re: Sample code for Remote control dashboard block?

by kcl1s on Mon Jan 08, 2018 2:44 pm

Thanks for the explanation. I will see if I can get it working in my project.

Keith

kcl1s
 
Posts: 539
Joined: Tue Aug 30, 2016 12:06 pm

Please be positive and constructive with your questions and comments.