I'm using the Pi to control some decorative lights. I turn the lights on and off via cron scripts and would like to get status on the lights as well. When I run the code below, it reports 'on' if the lights are on, but if they're off, they're turned on by the code.
#!/usr/bin/env ruby require 'rpi_gpio' RPi::GPIO.set_numbering :bcm RPi::GPIO.setup 18, :as => :output if RPi::GPIO.high? 18 print "Lights are on\n" else print "We're in the dark\n" end
If I change the setup to => :input, the pin goes low immediately and the lights go out.
What am I doing wrong?