Basic Information

This page allows you to fork a new project from an existing project (Visitor Counter). 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
Visitor Counter
'16/7/6 20:54
Count visitors and shows the number.
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.

var f3js = require('f3js'); var x = 5 /* Offset x [0, 100] */ , y = 5 /* Offset y [0, 100] */; f3js.drawRectangle(x, y, 195, 70); // load drivers. var grove = require('jsupm_grove'); var groveMotion = require('jsupm_biss0001'); var GCL = require("jsupm_my9221"); var tm1637 = require('jsupm_tm1637'); var LCD = require('jsupm_i2clcd'); // instantiate a circular led driver. var circle = new GCL.GroveCircularLED(3, 2); // Initialize 4-digit display and Jhd1313m1 LCD display var display = new tm1637.TM1637(4, 5); var myLcd = new LCD.Jhd1313m1(0, 0x3E, 0x62); myLcd.setColor(255, 0, 0); // put the circular led and displays. f3js.add(circle, x + 30, y + 30); f3js.add(display, x + 80, y + 20); f3js.add(myLcd, x + 150, y + 27.5); //f3js.drawRectangle(x + 105, y + 37.5, 5, 10); var level = 0, colon = true; function rotateSpinner() { var date = new Date(); var time = ("0" + (date.getHours()+9).toString()).slice(-2) + ("0" + date.getMinutes().toString()).slice(-2); display.writeString(time); display.setColon(colon); circle.setSpinner(level ++); if (level > 24) level = 0; } var circleInterval = setInterval(rotateSpinner, 100); // instantiate a motion sensor. var sensor = new groveMotion.BISS0001(8); // put the motion sensor. f3js.add(sensor, x + 80, y + 50); f3js.drawRectangle(x + 55, y + 44, 5, 10); var counter = 0, lastTime = 0; function readSensorValue() { var date = new Date(); // detect motion. if (sensor.value() > 0) { console.log('o ' + date.toString()); var time = date.getTime(); if (time - lastTime > 5000) { countUp(); } lastTime = date.getTime(); } colon = !colon; } function countUp() { counter ++; var counterString = '' + counter; if (counter % 10 === 1) counterString += 'st'; else if (counter % 10 === 2) counterString += 'nd'; else if (counter % 10 === 3) counterString += 'rd'; else counterString += 'th'; myLcd.setColor(255, 0, 0); myLcd.setCursor(0,0); myLcd.write(counterString + ' visitor'); myLcd.setCursor(1,0); myLcd.write('running on f3.js'); } var sensorInterval = setInterval(readSensorValue, 1000); process.on('SIGINT', function() { clearInterval(circleInterval); clearInterval(sensorInterval); });
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.