Skip to main content



The document is a continuation of the previous document, if you have landed directly on this page then, Please read from page Get started.

What is LED?

LED is an electronic device which emits light when current passes through it. It is used as a visual Indicator in Industries.

Oops!, No Image to display.

List of LED features implemented in Shunya stack

With Shunya stack you can make LED

  1. Turn On/Off.

Using Led Shunya stack

Requirements to use Led Shunya stack

  1. Shunya OS installed (supported Arm devices) i.e (Raspberry Pi)
  2. 1x LED
  3. 1x 220 ohm resistor

Steps to use Led Shunya stack

  1. Connect LED to your Arm device i.e (Raspberry Pi) .
  2. Turn On/Off LED.

Run the steps given below inside Shunya OS installed (supported Arm devices).

Step 1: Connect LED.

Oops!, No Image to display.

Step 2: Turn On/Off LED.

Let's take an example use case: Say we need to

  • Read data from the temperature sensor connected to Shunya and,
  • Turn on LED when the temperature is high.

Steps are :

  1. Start with an ready to use template for sending messages via MQTT

    git clone
    cd examples/simple-examples/operate-actuators
  2. Open the operate-actuators.c in an text editor and modify as per your use case.

  3. For our example, we need to first get the temperature data, add the code in your main() function

    float temperature = 76.98; /* For now lets assume that the temperature is 76.89 Celsius*/
  4. Initialize LED, modify the code

    int ledPin = 36; /*Define LED pin, Note this should be as per your connection */

    pinMode(ledPin, OUTPUT); /* Initializes LED pin as Output */

    LED should be initialized only once in the whole program. Calling pinMode() multiple times will cause error with the library.

  5. To turn on LED, modify the code

    float temperature = 76.89; /* Assume that the temperature is 76.89 deg C*/

    if (temperature == 70.00f){
    digitalWrite(ledPin, ON); /* Turn on LED */
    } else {
    digitalWrite(ledPin, OFF); /* Turn off LED */
  6. Once you are done editing, save and compile the code , by running

    mkdir build && cd build
    cmake ../
  7. Run the code

    sudo ./operate-actuators

Facing errors with the component?