#!/usr/bin/env ruby
require 'wiringpi'
io = WiringPi::GPIO.new(WPI_MODE_GPIO)
pin = 18
range = (15..255).to_a
range += range.reverse
def sleep_func(i)
sleep(0.004) if (i > 150)
sleep(0.005) if (i > 125) && (i < 151)
sleep(0.007) if (i > 100) && (i < 126)
sleep(0.010) if (i > 75) && (i < 101)
sleep(0.014) if (i > 50) && (i < 76)
sleep(0.018) if (i > 25) && (i < 51)
sleep(0.019) if (i > 1) && (i < 26)
end
loop do
range.each do |i|
io.pwmWrite pin, ((i/255.0) * 1000).to_i
sleep_func i
end
sleep 1
end
I get this error:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': cannot load such file -- wiringpi
(LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in 'require'
from ./pulse.rb:3:in '{main}'
The squiggly brackets are <>. The markdown didn't like them, hehe.
I read Gadgetoid's issue and dutifully installed ruby-dev, but the same error still occurs.
Not sure if it's bad coding, bad installing or something else. I'm a bit of a 'Ruby Newby', so please forgive me if I'm being stupid :)
When running the following Ruby file as root:
I get this error:
The squiggly brackets are <>. The markdown didn't like them, hehe. I read Gadgetoid's issue and dutifully installed ruby-dev, but the same error still occurs. Not sure if it's bad coding, bad installing or something else. I'm a bit of a 'Ruby Newby', so please forgive me if I'm being stupid :)