BeagleBone Black - Bonescript语法错误

时间:2017-03-28 11:49:57

标签: javascript debian beagleboneblack

我在BeagleBone黑色上使用Bonescript运行脚本时遇到问题。当我在Web浏览器中运行脚本时,它会正常执行。但是,当我尝试从终端窗口执行它们时,它们将无法运行。

#!/bin/bash
var b = require('bonescript');

var leds = ["USR0", "USR1", "USR2", "USR3", "P9_14"];

for(var i in leds) {
    b.pinMode(leds[i], b.OUTPUT);
}

var state = b.LOW;
for(var i in leds) {
    b.digitalWrite(leds[i], state);
}

setInterval(toggle, 1000);

function toggle() {
    state = (state == b.LOW) ? b.HIGH : b.LOW;
    for(var i in leds) {
        b.digitalWrite(leds[i], state);
    }
}




debian@beaglebone:~$ ./BlinkLED.js 
./BlinkLED.js: line 2: syntax error near unexpected token `('
./BlinkLED.js: line 2: `var b = require('bonescript');'

0 个答案:

没有答案