Created
January 16, 2017 19:54
-
-
Save mzgoddard/0a763f3e1b9676d2e9df31c8b25dafac to your computer and use it in GitHub Desktop.
Animate a 12 component adafruit neopixel ring with SPI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the interface to Tessel hardware | |
var tessel = require('tessel'); | |
var port = tessel.port.A; | |
var spi = new port.SPI({ | |
clockSpeed: 3.2*1000*1000, // 3.2MHz | |
cpol: 0, // Polarity - optional | |
cpha: 0, // Clock phase - optional | |
chipSelect: port.pin[7] // Chip select - optional | |
}); | |
var i = 11; | |
setInterval(function() { | |
spi.send(new Buffer([ | |
0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 0 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 1 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 2 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 3 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 4 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 5 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 6 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 7 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 8 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, i % 12 == 9 ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, ((i % 12) == 10) ? 0xcc : 0x88, | |
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, ((i % 12) == 10) ? 0xcc : 0x88, | |
])); | |
i++; | |
}, 1000 / 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mzgoddard how was the neopixel wired to your Tessel?