Created
December 3, 2017 22:57
-
-
Save cxm6467/259d5222e4d23dda5d113e4bffbd0940 to your computer and use it in GitHub Desktop.
Testing RaspberryPi and GPIO with ruby
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 'rpi_gpio' | |
RPi::GPIO.set_numbering :board | |
RPi::GPIO.set_warnings(false) | |
## Setup | |
PINS = [40, 11, 13, 15, 29, 31, 33, 35] | |
PINS.each do |pin| | |
RPi::GPIO.setup pin, :as => :output | |
RPi::GPIO.set_low pin | |
end | |
## Output | |
3.times do | |
PINS.each do |pin| | |
puts "Turning pin: #{pin} on" | |
RPi::GPIO.set_high pin | |
sleep(0.5) | |
puts "Turning pin: #{pin} off" | |
RPi::GPIO.set_low pin | |
end | |
end | |
puts "Cleaning up" | |
RPi::GPIO.reset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example of using Ruby and a RaspberryPi to test code integration with Christmas lights.