问题
I am trying to print a message to an OLED screen, everytime a button is pushed. Whenever I try running the code, I receive this "error". Im not sure what is causing it, or how I can resolve it. Any help would be appreciated.
var b = require('bonescript');
var button = "P8_12";
b.pinMode(button, b.INPUT);
var five = require('johnny-five');
var board = new five.Board();
var oled = require('oled-js');
var font = require('oled-font-5x7');
b.attachInterrupt(button, true, b.CHANGE, printTime)
function printTime(x) {
if(x.value == 1){
var d = new Date();
board.on('ready', function() {
var opts = {
width: 128,
height: 64,
address: 0x3c
};
var oled = new Oled(board, five, opts);
oled.setCursor(1, 1);
oled.writeString(font, 1, 'Button Pushed At:' +d, 1, true);
});
}
else{
var d = new Date();
board.on('ready', function() {
var opts = {
width: 128,
height: 64,
address: 0x3c
};
var oled = new Oled(board, five, opts);
oled.setCursor(1, 1);
oled.writeString(font, 1, 'Button Released At:' +d, 1, true);
});
}
}
EDIT: This is the output when I run
root@beaglebone:~# i2cdetect -r -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
And this is the output when I try to run my program.
1428684567492 Looking for connected device
I've double checked my wiring, and I believe that it is all correct, so Im not really sure what is causing the problem.
来源:https://stackoverflow.com/questions/29562688/looking-for-connected-device-error-when-interfacing-via-i2c-to-bbb