Block description

This block can be used when you want to use any generic sensor with the GraspIO board. Any analog or digital sensor not supported as an individual dedicated input block can be used through this block. You can use the Read functionality to understand the actual working and range of the sensor.

Hardware interface

Connect the external 5V sensor to any of the external sensor ports S1/S2/S3 on Cloudio.
Note: While connecting an external sensor to the Cloudio board, care must be taken to match the polarities of the sensor with that of the port (S1/S2/S3) that it is being connected to.

App interface and usage

Type/Mode:

You need to select the type of sensor, (or its mode of operation) before setting its parameters.
Gen An

Sensor in Analog mode:

In Analog mode, you can read analog values from the IR sensor and compare them against threshold integer values in the range 0 to 999.

Port:

Here, you can select the port the sensor is connected to - S1/S2/S3
Gen Port

Operator:

Here, you can select the operator to be used while comparing the sensor values against the threshold value.
Gen Op

Value:

You can set a threshold value for comparison in the range 0 to 999. You can press Read option to read/receive real-time values from the port selected. (Refer Read section)
Gen Val
After you set the parameters for the block, you can press Done to confirm and save your changes.

Sensor in Digital mode:

In Digital mode, you can read values from the sensor and compare them against digital states High and Low.
Gen Dig

Port:

Here, you can select the port the sensor is connected to - S1/S2/S3
Gen Dig Port

Operator:

Here, you can select the operator to be used while comparing the digital sensor values against the set threshold value.
Gen Dig Op

State:

You can set the threshold state to be compared against the state received from the sensor in digital mode.
Gen Dig State

You can use the Read option to read/receive real-time values from the port selected.

After you set the parameters for the block, you can press Done to confirm and save your changes.

Examples

Note: These are just code snippets to explain the working of the block. In this case, this code will be executed once and at the time of uploading the code.
You will need to use this snippet inside a Loop (infinitely) block if you want this code to run on the board for the entire duration that the board is on.

  1. The below project snippet uses the generic sensor in Analog mode. It turns the LED green if the value is less than or equal to 500, and turns it red when it crossed 500.
    Gen Ana Ex

  2. The below project snippet uses the generic sensor in Digital mode. It turns the LED green if the IR value is Low, and turns it red when it is High.
    Gen Dig Ex

Also read

Control blocks