Basic Information

This page allows you to fork a new project from an existing project (Lチカサンプル (Raspberry Pi)). The newly forked project will be listed in the IoT Projects page as a new entry. If you want to overwrite the existing project, please edit it instead.

* Photo URLs that end with any one of .jpg, .jpeg, .png or that are uploaded to the Gyazo web service in the PNG format (e.g.https://gyazo.com/hogehoge) are supported.

* Node.js entry point main: index.js and dependencies to the npm module dependencies: { f3js: (略) } will be automatically added and thus do not need to be in this form.

Card preview
'16/7/8 2:5
arc@dmz

Private Project

Unchecking this will make the project public and be listed in the IoT Projects page. The checkbox is unchecked by default since we want you to share the projects! Additionally, you cannot check this unless you are logged in. Once you make the project public, it cannot be undone. (Any edits to the project except for forking will also be public.)

Source Code

Provide the source code of a microcontroller or tiny computer in JavaScript. Node.js-based computers are supported. Require f3js package and use its API to design the device enclosure.

/** * LED blinking app for Intel Edison * see http://f3js.org/projects/edit?id=182 for Raspberry Pi version */ // load GrovePi module var GrovePi = require('node-grovepi').GrovePi; if (typeof GrovePi.sensors.DigitalOutput === 'object') { // old npm module impl forgot "module.exports," resulting in an empty JS object. // fill the content by myself... // cf. https://github.com/DexterInd/GrovePi/commit/513c67e33e9f8fb99617067ea40d8e52da4e014f#diff-15b138624f4846fbbec7ff8dd7031505 GrovePi.sensors.DigitalOutput = function GenericDigitalOutputSensor(pin) { GrovePi.sensors.base.Digital.apply(this, Array.prototype.slice.call(arguments)); }; DigitalOutput.prototype = new GrovePi.sensors.base.Digital(); DigitalOutput.prototype.on = function() { this.board.pinMode(this.board.OUTPUT); var write = this.board.writeBytes( GrovePi.commands.dWrite.concat([this.pin, 1, GrovePi.commands.unused])); return !!write; }; DigitalOutput.prototype.off = function() { this.board.pinMode(this.board.OUTPUT); var write = this.board.writeBytes( GrovePi.commands.dWrite.concat([this.pin, 0, GrovePi.commands.unused])); return !!write; }; } // initialize connection to the GrovePi board. var board = new GrovePi.board({ debug: true , onError: function (err) { console.error(err); } , onInit: function (init) { if (!init) { // onError is called. return; } console.log('GrovePi version:', board.version()); led = new GrovePi.sensors.DigitalOutput(2); waiting = setInterval(blink, 1000); } }); // turn the LED on and off 10 times, pausing one second // between transitions var led = new GrovePi.sensors.DigitalOutput(2) , waiting, i = 0; function blink() { if (i ++ % 2 === 0) led.on(); else led.off(); if (i >= 20) onExit(); } // create a box to hold the LED var f3js = require('f3js') , width = 130 , height = 105 , thickness = 45 , c = f3js.createContainer() , rect = c.drawJointRectangle( 0, 0, width, height); rect.jointHeight = 2; var planes = rect.extrude(thickness); // set some offset c.x = 10; c.y = 10; // put an LED module c.add(led, width / 2, height / 2); // open a hole for the wire c.drawRectangle(width / 2 - 10, height / 2 + 20, 20, 10); // put side boards planes[0].x = 0; planes[0].y = height + rect.jointHeight; c.add(planes[0]); planes[1].x = width; planes[1].y = height + rect.jointHeight; c.add(planes[1]); planes[2].x = height; planes[2].y = height + thickness + rect.jointHeight; c.add(planes[2]); planes[3].x = 0; planes[3].y = height + thickness + rect.jointHeight; c.add(planes[3]); planes[4].x = width; planes[4].y = 0; c.add(planes[4]); // put a side hall planes[3].drawRectangle( 5, thickness - rect.jointHeight - 15, height - 10, 10); // initialize the application console.log('ready'); process.on('SIGINT', onExit); board.init(); // clean up before the death function onExit(err) { if (i % 2 !== 0) led.off(); if (waiting) clearInterval(waiting); if (board) board.close(); process.removeAllListeners(); process.exit(); if (err) console.error(err); }
Customization

This content does not allow any customization.

Layout view options
Adding comments to variable declarations in the source code populate various GUI widgets in the "Customization" section depending on their types.

Design Alternatives

Modules

No modules are required for this project.

Layout
Program

Login first to use this feature.