Tessel2로 L천하 테스트.

Tessel2의 L 토치카를 시험해 보겠습니다.

Tessel2의 CLI 명령 설치 및 오류 방지도 있지만, 최근의 노드.jsv6라면 특별한 오류가 발생하지 않습니다.
Hello World 느낌으로 Tessel2로 맞춰보세요.
그나저나 Tessel2 기술은 아직 통과되지 않았으니 일본 내에서 사용할 때는 차단실과 전파암실을 이용하세요.
차폐실DMM.make AKIBA도 사용했다.https://www.instagram.com/p/BGLk55xkjg1/
$ t2 init
Initializing tessel repository...
Created package.json.
Wrote 'Hello World' to index.
디렉토리의 index입니다.js와 패키지입니다.json을 생성합니다.
$ ls
index.js     package.json
index.js
// Import the interface to Tessel hardware
var tessel = require('tessel');

// Turn one of the LEDs on to start.
tessel.led[2].on();

// Blink!
setInterval(function () {
  tessel.led[2].toggle();
  tessel.led[3].toggle();
}, 100);

console.log("I'm blinking! (Press CTRL + C to stop)");
0.1초마다 한 번씩 미치기(빨리w)
$ t2 run index.js
INFO Looking for your Tessel...
INFO Connected to n0bisuke.
INFO Building project.
INFO Writing project to RAM on n0bisuke (3.072 kB)...
INFO Deployed.
INFO Running index.js...
I'm blinking! (Press CTRL + C to stop)

ES2015로 변경


ES2015도 갈 수 있어요.이런 느낌이에요.
index.js
'use strict'

const tessel = require('tessel');
tessel.led[2].on();

setInterval(() => {
  tessel.led[1].toggle();
  tessel.led[2].toggle();
  tessel.led[3].toggle();
}, 1000);
기본적으로 1, 2, 3 세 개의 LED를 사용할 수 있을 것 같습니다.

겸사겸사 말씀드리지만, 4는 틀렸습니다.
省略
・
・
・
  tessel.led[4].toggle();
               ^

TypeError: Cannot read property 'toggle' of undefined
    at null._repeat (/tmp/remote-script/index.js:10:16)
    at wrapper [as _onTimeout] (timers.js:264:19)
    at Timer.listOnTimeout (timers.js:92:15)

좋은 웹페이지 즐겨찾기