led-hands-rpi/main.rb
2019-01-27 19:59:09 +00:00

36 lines
455 B
Ruby
Executable File

# frozen_string_literal: true
#!/usr/bin/env ruby
require 'bundler'
require 'rpi_gpio'
Bundler.setup
Bundler.require
BLUE = 37
WHITE = 35
RED = 33
GREEN = 31
YELLOW = 29
leds = [BLUE, WHITE, RED, GREEN, YELLOW]
io = RPi::GPIO
io.set_numbering :board
leds.each do |led|
io.setup led, as: :output, initialize: :low
io.set_low led
end
10.times do
5.times do |i|
sleep 0.5
io.set_high leds[i]
io.set_low leds[i - 1]
end
end
io.reset