I have a setup like below:
The script is supposed to turn the led on, sleep and turn it off again. And the script does work.
import RPi.GPIO as GPIO
import time
# This script will turn on the LED for 1 second and turn it off again
# setup GPIO
GPIO.setmode(GPIO.BCM)
# disable warnings
GPIO.setwarnings(False)
# set GPIO.OUT to pin 18
GPIO.setup(18,GPIO.OUT)
# turn on LED
print "LED on"
GPIO.output(18,GPIO.HIGH)
# wait for 1 second
time.sleep(1)
# turn off led
print "LED off"
GPIO.output(18,GPIO.LOW)
If I reboot the pi the led suddenly is on again and I wonder why. Is it because I am missing something important about the pi's functionality or am I making mistakes here? By the way the same behavior occurs with rgb leds too.
I also read up on GPIO.setmode(GPIO.BCM)
and it seems that the only difference between the modes BCM
and BOARD
are the number one uses when referring to pins, or might the mode be the issue?