Open
Description
Hi, I created a script that blinks the LEDs on channel 12, 7, and 8.
I am using Arch Linux ARM on Rapsberry Pi 3 model B.
My code:
#!/usr/bin/ruby -w
require 'rpi_gpio'
Object.prepend(RPi::GPIO)
set_warnings(false)
set_numbering(:board)
pins = [12, 7, 8].each { |x| setup(x, as: :output) }
c = pins.size.times.map { |x| ?- * x.next }
begin
pins.each_with_index do |x, i|
print "\e[2KPin #{c[i]}> #{x}\r"
set_high(x)
Kernel.sleep(0.5)
set_low(x)
Kernel.sleep(0.5)
end while true
rescue SignalException, Interrupt, SystemExit
pins.each(&method(:clean_up))
exit 0
rescue Exception => e
Kernel.warn(e)
Kernel.sleep 1
retry
end
I see irregular flashes. The LED [at pin] 12 turns on and off first. Then LED 7, then LED 8 without turning LED 7 off. Then LED 12 goes on and off. Then 7 goes off and on after a while. Then LED 8 goes off and on and it continues. It looks messy. This shouldn't happen! Same happens with PWM...
Metadata
Metadata
Assignees
Labels
No labels