Want to stay informed? Share your e-mail address for news:

Click here for our GitHub Repository

Node.js for Microcontrollers

Modifying the Blink LED example to letting the user control the LED through a website the microcontroller serves is just basic Node.JS programming.

Enter the following code into /index.js:

Is the example not working as expected?

Try checking the status with lowsync status.

To start or restart the program call lowsync start.

You can also check for any (error-) output by calling lowsync monitor and then fix any errors you find in your editor.

Remember to call lowsync sync after any changes you make.

let http = require('http');
let fs = require('fs');
let gpio = require('gpio');

let state = 0;

fs.readFile('/client.html', 'utf8', (err, page) => {
    if(err) {

    http.createServer((req, res) => {
        if (req.url == '/Toggle') {
            state = !state;
        } else if (req.url == '/') {
            res.writeHead(200, { 'Content-Type': 'text/html' });
        } else {

Enter the following code into /client.html. This file will be sent to the web browser.

        <script type="text/javascript">
            function toggle() {
                var request = new XMLHttpRequest();
                request.open('GET', '/Toggle', true);
        <p>The example page, served by low.js</p>
        <p><input type="button" value="Toggle LED" onclick="javascript: toggle()"></p>

Sync and restart program. You should see the website when pointing your web browser to the microcontroller's IP.