Sha256: 5401b80111159d326c0aae9b701b36e781ba1f5e382ece6057e84885706135ee
Contents?: true
Size: 767 Bytes
Versions: 7
Compression:
Stored size: 767 Bytes
Contents
# # Walk a single pixel along the length of an APA102 strip and back, # changing color each time it returns to position 0. # require 'bundler/setup' require 'denko' RED = [255, 0, 0] GREEN = [0, 255, 0] BLUE = [0, 0, 255] WHITE = [255, 255, 255] COLORS = [RED, GREEN, BLUE, WHITE] PIXELS = 8 # Move along the strip and back, one pixel at a time. positions = (0..PIXELS-1).to_a + (1..PIXELS-2).to_a.reverse board = Denko::Board.new(Denko::Connection::Serial.new) # Use the default hardware SPI bus. bus = Denko::SPI::Bus.new(board: board) strip = Denko::LED::APA102.new(bus: bus, length: PIXELS) loop do COLORS.each do |color| positions.each do |index| strip.clear strip[index] = color strip.show sleep 0.05 end end end
Version data entries
7 entries across 7 versions & 1 rubygems