Example Code for Intel Joule-Blink LED

Last revision 2026/01/24

This article offers a comprehensive guide to blinking an LED using Intel Joule with Node.js, including hardware setup and troubleshooting tips, ensuring a smooth and successful implementation of the project.

Hardware Preparation

Software Preparation

  1. This Demo prefers "Reference Linux* OS for IoT" instead of Ubuntu or Windows 10 IOT.
  2. You can keep your OS updated via ,If there is something wrong with your board, you can always flash the BIOS to reset your board.
  3. There is a known software issue in MRAA which prevents GPIO working properly. We reported it to Intel and they solved it quickly. However, it will not be released until fully tested.
  4. Although It is a better idea to wait for the the fully tested version, if you are willing to have a try, you can get here and update the latest version.
  • Login your Joule via Putty or other serial tools.
  • Create a Node JS example using vi.
vi blink.js
var m = require('mraa'); //require mraa
console.log('MRAA Version: '   m.getVersion()); //write the mraa version to the console

var myLed = new m.Gpio(27); //Corresponding to ISH_GPIO4
myLed.dir(m.DIR_OUT); //set the gpio direction to output
var ledState = true; //Boolean to hold the state of Led

function periodicActivity()
{
myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low)
ledState = !ledState; //invert the ledState
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds)
}

periodicActivity(); //call the periodicActivity function
  • Run the node sample in the bash.
node blink.js
  • The LED starts to blink.
  • To stop running the demo.
  • You have done the first project on Intel Joule. Well Done!

Wiring Diagram

DFR0465-LED wiring diagram

NOTE: Tip to get the right pin number For example
DFR0465-Intel_joule_correct_pin GPIO Pin 4 on board >> ISH_GPIO4 >> D 27, so the pin number in the code should be 27. Please check the Board Overview for other pins.

Sample Code

C++ with MRAA, set GPIO27 as output and cycle its level.

#include <mraa.hpp>
#include <unistd.h>

int main() {
    mraa::Gpio* led = new mraa::Gpio(27); // 对应ISH_GPIO4
    led->dir(mraa::DIR_OUT);
    
    while (true) {
        led->write(1); // High Level
        sleep(1);
        led->write(0); // Low Level
        sleep(1);
    }
    
    delete led;
    return 0;
}

Result

LED on GPIO27 blinks every 1s, the program runs in an infinite loop.

Was this article helpful?

TOP