Basic Information

This page allows you to fork a new project from an existing project (Camera w/wo countdown). 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
Camera w/wo countdown
'16/7/20 1:41
A camera whose features and appearance can be customized! With or without a countdown timer.
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.

// instantiate the camera var Camera = require('jsupm_grovescam').GROVESCAM; var camera = new Camera(0); if (camera.setupTty && !camera.setupTty()) { console.log('failed to initialize connection to the camera'); process.exit(1); } if (camera.init && camera.init()) console.log('camera initialized'); else console.error('init() failed'); // instantiate sensors and actuators var groveSensor = require('jsupm_grove'); var gcl = require("jsupm_my9221"); var button = new groveSensor.GroveButton(3); // set layout parameters var f3js = require('f3js') , x = 10 , y = 10 , useCountdown = true /* Use the countdown feature. */ , width = useCountdown ? 130 : 60 , height = 105 , thickness = 45 /* Thickness [10, 100] */ , dw = 5 /* Joint width [0, 10] */ , dh = 2 /* Joint height (panel thickness) [0, 10] */; // put base board var rect = f3js.drawJointRectangle(x, y, width, height, dw, dh, true); var planes = rect.extrude(thickness); planes[4].x = width; planes[4].y = 0; f3js.add(planes[4]); // put sensors and actuators var leftMargin = 28 // Left margin [0, 100] , topMargin = 30; // Top margin [0, 100] f3js.add(camera, { x: x + leftMargin + 0, y: y + topMargin + 0 }); f3js.add(button, { x: x + leftMargin + 0, y: y + 75 }); var circle; if (useCountdown) { circle = new gcl.GroveCircularLED(5, 4); f3js.add(circle, { x: x + width - 30, y: y + topMargin + 0 }); 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; planes[0].x = x; planes[0].y = y + height + margin; f3js.add(planes[0]); planes[1].x = x + width; planes[1].y = y + height + margin - dh; f3js.add(planes[1]); planes[2].x = x + height; planes[2].y = y + height + thickness + margin; f3js.add(planes[2]); planes[3].x = x; planes[3].y = y + height + thickness + margin; f3js.add(planes[3]); // put a side hall planes[3].drawRectangle( 5, thickness - 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) { // immediately take a photo takePicture(); } else { // or use countdown 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) { takePicture(); clearInterval(countDown); ready = true; } }, cycle); } } } setInterval(readButtonValue, 100); function takePicture() { if (camera.preCapture && camera.preCapture()) console.log('camera prepared for capturing images'); else console.error('camera failed to prepare for capturing images'); if (camera.doCapture()) console.log('camera capturing an image'); else console.log('camera failed to capture an image'); if (camera.getImageSize() > 0) { console.log('storing an image ...'); if (camera.storeImage('image.jpg')) console.log('camera successfully captured the image: image.jpg'); else console.log('camera failed to store the captured image: image.jpg'); } } var var83594 = false; // *proposed* Shutter noise ON/OFF var var32221 = false; // *proposed* Flash
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.