first noodles
This commit is contained in:
parent
9519c85e7b
commit
cbcf60a3ed
8
Gemfile
Normal file
8
Gemfile
Normal file
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
||||
|
||||
# gem "sinatra"
|
||||
gem 'rpi_gpio'
|
13
Gemfile.lock
Normal file
13
Gemfile.lock
Normal file
@ -0,0 +1,13 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
rpi_gpio (0.3.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rpi_gpio
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.1
|
35
main.rb
Executable file
35
main.rb
Executable file
@ -0,0 +1,35 @@
|
||||
# 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
|
Loading…
Reference in New Issue
Block a user