Select

Data

DataTypeValues
Select positionunsigned char0 - position A
1 - position B
2 - position C
3 - position D
etc...

The "select" transmits information to the microcontroller about one of several of its provisions. The switch may be installed in one of several positions. To change position of the switch is necessary to move the slider to its new position, or touch directly at the new position.

Settings

Settings of "select" allow to specify the different values:

  • Variable name - name of the select and the variable in the source code for the microcontroller, allow to set a name for the variable of C rules.
  • Count of positions - sets the number of possible positions of the "select". Can take a value from 2 to 10.
  • Orientation - You can set the orientation of the "select" on the interface field. Orientation can be "vertical" or "horizontal".

Code example

A common example showing how to check the current position of the four position switch:


  if (RemoteXY.select_1==0) {
    /*  current position A */
  }
  else if (RemoteXY.select_1==1) {
    /*  current position B */
  }
  else if (RemoteXY.select_1==2) {
    /*  current position C */
  }
  else if (RemoteXY.select_1==3) {
    /*  current position D */
  }

Same thing, but using the operator switch .. case:


  switch (RemoteXY.select_1) {
    case 0:
      /*  current position A */
      break;
    case 1:
      /*  current position B */
      break;
    case 2:
      /*  current position C */
      break;
    case 3:
      /*  current position D */
      break;
  }

The following example shows how you can control up to four pins of the microcontroller, including them depending on the current position of the switch.

Code for Arduino IDE, control pins 4..7:


  if (RemoteXY.select_1==0) digitalWrite(4, HIGH);
  else digitalWrite(4, LOW);
  if (RemoteXY.select_1==1) digitalWrite(5, HIGH);
  else digitalWrite(5, LOW);
  if (RemoteXY.select_1==2) digitalWrite(6, HIGH);
  else digitalWrite(6, LOW);
  if (RemoteXY.select_1==3) digitalWrite(7, HIGH);
  else digitalWrite(7, LOW);