Skip to content

Instantly share code, notes, and snippets.

@cxm6467
Created December 3, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cxm6467/259d5222e4d23dda5d113e4bffbd0940 to your computer and use it in GitHub Desktop.
Save cxm6467/259d5222e4d23dda5d113e4bffbd0940 to your computer and use it in GitHub Desktop.
Testing RaspberryPi and GPIO with ruby
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
@cxm6467
Copy link
Author

cxm6467 commented Oct 11, 2021

This is an example of using Ruby and a RaspberryPi to test code integration with Christmas lights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment