From cbcf60a3ed1aa8bc40ccf9f98a901b0c3800dcbf Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Sun, 27 Jan 2019 19:59:09 +0000 Subject: [PATCH] first noodles --- Gemfile | 8 ++++++++ Gemfile.lock | 13 +++++++++++++ main.rb | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100755 main.rb diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..91b5ecb --- /dev/null +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..bd4d528 --- /dev/null +++ b/Gemfile.lock @@ -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 diff --git a/main.rb b/main.rb new file mode 100755 index 0000000..512fc1b --- /dev/null +++ b/main.rb @@ -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