https://github.com/fivdi/pigpio :: npm install pigpio (and npm install assert)
pigpiodがうごいてなかればsudoで起動する たまに
【電子工作】Raspberry Pi OSでpigpioを使ったC言語プログラム実行時に「initInitialise: Can’t lock /var/run/pigpio.pid」とエラーが出た
sudo killall pigpiod で解決する
const Gpio = require('pigpio').Gpio; const led = new Gpio(17, {mode: Gpio.OUTPUT}); let dutyCycle = 0; setInterval(() => { led.pwmWrite(dutyCycle); dutyCycle += 5; if (dutyCycle > 255) { dutyCycle = 0; } }, 20); これでLEDのpwmできた
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
ーーーーーーーーaqm0802ーーーーーーーーーーーーーーーーーーーーーーーーーhttp://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_3_node_js_i2c_lcd/
:: aqm0820 3v,scl1,sda1,gndで動かす
(どうも手持ちのaqm0802の調子がわるくゼロ行が表示できん!機会あれば再購入?)
以下でaqm0802のi2c情報確認できた
^^^^^^^^^^^^^^^^^^^^
'use strict';
// When run, this program will output the same information as the
// command 'i2cdetect -y -r 1'
const fs = require('fs');
const i2c = require('i2c-bus');
const i2c1 = i2c.openSync(1);
const EBUSY = 16; /* Device or resource busy */
const scan = (first, last) => {
fs.writeSync(0, ' 0 1 2 3 4 5 6 7 8 9 a b c d e f');
for (let addr = 0; addr <= 127; addr += 1) {
if (addr % 16 === 0) {
fs.writeSync(0, '\n' + (addr === 0 ? '0' : ''));
fs.writeSync(0, addr.toString(16) + ':');
}
if (addr < first || addr > last) {
fs.writeSync(0, ' ');
} else {
try {
i2c1.receiveByteSync(addr);
fs.writeSync(0, ' ' + addr.toString(16)); // device found, print addr
} catch (e) {
if (e.errno === EBUSY) {
fs.writeSync(0, ' UU');
} else {
fs.writeSync(0, ' --');
}
}
}
}
fs.writeSync(0, '\n');
};
scan(0x3, 0x77);
^^^^^^以下はあっさり成功^^^^^^^^^^^^^^^^^^^^^^
https://qiita.com/kobuchin1/items/da527d0997a1f66b837b :: dht11 for raspi
https://qiita.com/ekzemplaro/items/3a982b259db4b1cf19ad :: onoff lib for raspi
0 件のコメント:
コメントを投稿