-
-
Save b1nary/4520331 to your computer and use it in GitHub Desktop.
Colorfully testing RGB Leds with ws2801 chips
This file contains 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
require 'ws2801' | |
sleep 10 | |
WS2801.gen | |
rainbow = [ | |
[255,0,0], | |
[255,165,0], | |
[255,255,0], | |
[0,128,0], | |
[0,0,255], | |
[075,0,130], | |
[238,130,238] | |
] | |
30.times do |i| | |
WS2801.gen | |
WS2801.length.times do |i| | |
WS2801.put i, rand(255), rand(255), rand(255) | |
end | |
WS2801.write | |
sleep(0.1) | |
end | |
30.times do |i| | |
WS2801.gen | |
WS2801.length.times do |i| | |
color = rainbow[rand(rainbow.size)] | |
WS2801.put i, color[0], color[1], color[2] | |
end | |
WS2801.write | |
sleep(0.1) | |
end | |
50.times do |i| | |
WS2801.gen | |
if i % 2 == 0 | |
WS2801.fill(0,0,0) | |
else | |
WS2801.fill(255,255,255) | |
end | |
WS2801.write | |
sleep(0.02) | |
end | |
25.times do |i| | |
WS2801.gen | |
WS2801.put i, 0, 255, 100 | |
WS2801.write | |
sleep(0.02) | |
end | |
25.times do |i| | |
WS2801.gen | |
WS2801.put 25-i, 0, 255, 100 | |
WS2801.write | |
sleep(0.02) | |
end | |
25.times do |i| | |
WS2801.gen | |
WS2801.put i, 255, 255, 50 | |
WS2801.write | |
sleep(0.04) | |
end | |
25.times do |i| | |
WS2801.gen | |
WS2801.put 25-i, 255, 0, 50 | |
WS2801.write | |
sleep(0.04) | |
end | |
255.times do |i| | |
WS2801.fill(0,i,0) | |
WS2801.write | |
sleep(0.005) | |
end | |
255.times do |i| | |
WS2801.fill(0,255-i,i) | |
WS2801.write | |
sleep(0.005) | |
end | |
255.times do |i| | |
WS2801.fill(i,0,255-i) | |
WS2801.write | |
sleep(0.005) | |
end | |
255.times do |i| | |
WS2801.fill(255-i,0,0) | |
WS2801.write | |
sleep(0.005) | |
end | |
WS2801.gen | |
WS2801.write |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment