带覆盆子Pi的可寻址LED灯带

2024-10-01 17:38:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经研究了一段时间了,没有发现任何结论。在

我想用一个可寻址的LED和我的树莓皮,可能有节点.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

以下是我对一个发光二极管,但不适用于条形:

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吗?我走错路了吗?在

谢谢!!我在这件事上费尽了心思。在


Tags: thetoledgpiovarfunctionexportchange
1条回答
网友
1楼 · 发布于 2024-10-01 17:38:03

看看这个教程。虽然我不完全理解板条的工作方式,我已经设法让我的圆周率随机使用这一代码,但我的带钢不是由同一个制造商生产的。我发现用我的Arduino来编写这个程序要容易得多。在Make杂志上也有一些关于使用Adafruit的LED条带和面板的教程。在

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

干杯

史蒂夫

相关问题 更多 >

    热门问题