Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'rubygems' # Tells ruby that we want to be able to import libraries from Rubygems
- require 'pi_piper' # This gem allows us to control our Raspberry PI GPIO Ports.
- # Tell Ruby that we want to create a new variable called 'red_pin'
- # ':pin => 17' tells Ruby that the pin is on GPIO 17
- # ':direction' tells the system that we want to make the pin an output
- red_pin = PiPiper::Pin.new(:pin => 17, :direction => :out)
- green_pin = PiPiper::Pin.new(:pin => 27, :direction => :out)
- blue_pin = PiPiper::Pin.new(:pin => 22, :direction => :out)
- # We're now going to create a simple loop.
- loop do
- red_pin.on # Turn the Red LED on
- sleep 1 # Wait for 1 second
- red_pin.off # Turn the Red LED off
- green_pin.on # Turn the Green LED on
- sleep 1 # Wait for 1 second
- green_pin.off # Turn off the Green LED
- blue_pin.on # Turn on the Blue LED
- sleep 1 # Wait for one second
- blue_pin.off # Turn off the Blue LED
- # This loop will continue on infinitely until you kill the program.
- # You can kill the program by typing the shortcut CTL(control)+c
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement