2013-11-02 54 views
1

我一直在研究這一段時間,還沒有發現任何結論。樹莓派的可編址LED燈帶

我想用我的Raspberry pi的可尋址LED,可能帶有node.js(npm gpio)或python。我對電路知之甚少,但我有一種感覺,樹莓派沒有數字寫入能力。

鋼帶有4個輸入(5V,SDI,CKI,GND) 我使用這個:http://www.amazon.com/gp/product/B008F05N54/ref=oh_details_o01_s00_i00?ie=UTF8&psc=1

以下是我對那個工作,但不帶單LED:

var gpio = require("gpio"); 
var gpio22, gpio4, intervalTimer; 

// Flashing lights if LED connected to GPIO22 
gpio22 = gpio.export(22, { 
    ready: function() { 
     inervalTimer = setInterval(function() { 
     gpio22.set(); 
     setTimeout(function() { gpio22.reset(); }, 500); 
     }, 1000); 
    } 
}); 

// Lets assume a different LED is hooked up to pin 4, the following code 
// will make that LED blink inversely with LED from pin 22 
gpio4 = gpio.export(4, { 
    ready: function() { 
     // bind to gpio22's change event 
     gpio22.on("change", function(val) { 
     gpio4.set(1 - val); // set gpio4 to the opposite value 
     }); 
    } 
}); 

// reset the headers and unexport after 10 seconds 
setTimeout(function() { 
    clearInterval(intervalTimer);   // stops the voltage cycling 
    gpio22.removeAllListeners('change'); // unbinds change event 
    gpio22.reset();      // sets header to low 
    gpio22.unexport();      // unexport the header 

    gpio4.reset(); 
    gpio4.unexport(function() { 
     // unexport takes a callback which gets fired as soon as unexporting is done 
     process.exit(); // exits your node program 
    }); 
}, 10000) 

我想要做的就是得到這個與我的工作尋址什麼LED燈條:

有誰知道,如果我能做到這一點與數字寫我的尋址LED工作?我接近這個錯誤嗎?

謝謝!我已經難倒了。

+0

我有一種感覺,有人將關閉這個線程。讓你的問題更通用 - 即沒有覆盆子pi。 –

+1

這看起來像使用與[this]相同的芯片組(http://www.adafruit.com/products/738)。也許你可以嘗試看看[這個庫](https://github.com/RussTheAerialist/node-spi)。 – Sean

回答

1

看看本教程。儘管我沒有完全理解這些條的工作方式,但我已經設法讓我的工作以一種隨機的方式與我的Pi使用此代碼一起工作,但我的條並非由同一製造商生產。我發現使用我的Arduino編程地帶要容易得多。 Make雜誌中還有一些關於使用Adafruit的LED燈條和麪板的很好的教程。

https://learn.adafruit.com/light-painting-with-raspberry-pi/overview

乾杯

史蒂夫