Basic Information

This page allows you to edit the existing project (カウントダウン機能つき?カメラ). The edited project will replace the existing entry in the IoT Projects page. If you want to add a new entry based on the project, please fork from 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/3/14 14:29
サーキュラーLEDを用いたカウントダウン機能を付けられるカメラです。
arc@dmz

Private Project

This project is already public and cannot be made private.

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.

// get serial port var mraa = require('mraa'); mraa.init(); var port = new mraa.Uart(0).getDevicePath(); // instantiate the camera var Camera = require('jsupm_grove_camera'); var camera = new Camera(port); // instantiate sensors and actuators var groveSensor = require('jsupm_grove'); var gcl = require("jsupm_grovecircularled"); var button = new groveSensor.GroveButton(3); // set layout parameters var f3js = require('f3js') , x = 10 , y = 10 , width = 130 , height = 105 , thickness = 42 , dw = 5 /* ぎざぎざ幅 [0, 10] */ , dh = 2 /* 板厚 [0, 10] */ , useCountdown = true /* カウントダウン機能を使う */; // put base board f3js.drawDovetailRectangle(x, y, width, height, dw, dh, true); f3js.drawDovetailRectangle(x + width + dh, y, width, height, dw, dh, true); // put sensors and actuators var leftMargin = 28 // Left margin [0, 100] , topMargin = 30; f3js.add(camera, x + leftMargin, y + topMargin); f3js.add(button, x + leftMargin, y + 75); var circle; if (useCountdown) { circle = new gcl.GroveCircularLED(5, 4); f3js.add(circle, x + width - 30, y + topMargin); f3js.drawRectangle(x + width - 30 - 6, y + topMargin - 18, 12, 3); } // draw circles... for (var i = 0; i < 7; i ++) { f3js.drawCircle( x + width - (i + 1) * 10 , y + height - 10 , 1); // additional holes } // put side boards var margin = dh; f3js.drawDovetailRectangle( x, y + height + margin - dh, width, thickness, dw, dh, true, false); f3js.drawDovetailRectangle( x + width + dh, y + height + margin - dh, width, thickness, dw, dh, true, false); f3js.drawDovetailRectangle( x + dw, y + height + thickness + margin - dh, height, thickness, dw, dh, true, false, true); f3js.drawDovetailRectangle( x + dw + width + dh, y + height + thickness + margin - dh, height, thickness, dw, dh, true, false, true); // put a side hall f3js.drawRectangle( x + dw + 5, y + height + thickness * 2 + margin - dh - 15, height - 10, 10); // take a picture after a while var ready = true; function readButtonValue() { // detect button push if (ready && button.value() > 0) { ready = false; if (!useCountdown) { // use countdown camera.takePicture('/home/root/test.jpg'); } else { // or immediately take a photo var cycle = 300 , maxLevel = 24 , level = maxLevel; // start countdown timer var countDown = setInterval(function() { level --; console.log("countdown: ", level); circle.setLevel(level); // take a picture! if (level <= 0) { camera.takePicture('/home/root/test.jpg'); clearInterval(countDown); ready = true; } }, cycle); } } } setInterval(readButtonValue, 100);
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.