OS/Orange PI
Orange Pi Zero - node.js 설치
파란크리스마스
2017. 12. 17. 20:18
728x90
출처 : orange-pi-gpio - npm
GitHub - BorisKotlyarov/orange-pi-gpio
Arduino Slovakia - Orange Pi Zero and Node.js
node.js 6.X 설치
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - $ sudo apt-get install -y nodejs
node.js 8.X 설치
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - $ sudo apt-get install -y nodejs
node.js 설치 확인
$ node -v v8.9.3 $ npm -v 5.5.1
orange-pi-gpio 라이브러리 설치
출처 : GitHub - BorisKotlyarov/orange-pi-gpio
$ npm i orange-pi-gpio npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json' npm WARN pi No description npm WARN pi No repository field. npm WARN pi No README data npm WARN pi No license field. + orange-pi-gpio@1.0.2 added 1 package in 6.975s
LED 제어
소스
const Gpio = require('orange-pi-gpio'); let gpio14 = new Gpio({pin:14, mode: 'out', ready: ()=>{ let value = 1; setInterval(function() { process.stdout.write('\x1B[2J\x1B[0f\u001b[0;0H'); if(value){ console.log('\x1b[32m%s\x1b[0m', `ON`); } else { console.log('\x1b[31m%s\x1b[0m', `OFF`); } gpio14.write(value); value = +!value; }, 50); }});
실행
$ node LEDDemo.js