Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems' # Tells ruby that we want to be able to import libraries from Rubygems
  4. require 'pi_piper' # This gem allows us to control our Raspberry PI GPIO Ports.
  5.  
  6. # Tell Ruby that we want to create a new variable called 'red_pin'
  7. # ':pin => 17' tells Ruby that the pin is on GPIO 17
  8. # ':direction' tells the system that we want to make the pin an output
  9.  
  10. red_pin = PiPiper::Pin.new(:pin => 17, :direction => :out)
  11. green_pin = PiPiper::Pin.new(:pin => 27, :direction => :out)
  12. blue_pin = PiPiper::Pin.new(:pin => 22, :direction => :out)
  13.  
  14. # We're now going to create a simple loop.
  15. loop do
  16. red_pin.on # Turn the Red LED on
  17. sleep 1 # Wait for 1 second
  18. red_pin.off # Turn the Red LED off
  19. green_pin.on # Turn the Green LED on
  20. sleep 1 # Wait for 1 second
  21. green_pin.off # Turn off the Green LED
  22. blue_pin.on # Turn on the Blue LED
  23. sleep 1 # Wait for one second
  24. blue_pin.off # Turn off the Blue LED
  25.  
  26. # This loop will continue on infinitely until you kill the program.
  27. # You can kill the program by typing the shortcut CTL(control)+c
  28.  
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement