tony1812
Posts: 198
Joined: Sat Jul 15, 2017 12:40 pm
Location: Boston MA.

BCN vs BOARD

Sun Jul 16, 2017 9:03 pm

Hi, I have this example from this link: https://thepihut.com/blogs/raspberry-pi ... -gpio-pins
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
print "LED on"
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(18,GPIO.LOW)

It works fine. But I prefer to use the BOARD numbering rather then BCM, How can I switch to BOARD?
I changed to BOARD, renumbered to output 12 like this:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BRORD)
GPIO.setwarnings(False)
GPIO.setup(12, GPIO.OUT)
print "LED on"
GPIO.output(12, GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(12,GPIO.LOW)
Than I got a syntax error, what did I do wrong?

Thanks

User avatar
Paeryn
Posts: 1673
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: BCN vs BOARD

Sun Jul 16, 2017 9:14 pm

tony1812 wrote:Hi, I have this example from this link: https://thepihut.com/blogs/raspberry-pi ... -gpio-pins
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
print "LED on"
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(18,GPIO.LOW)

It works fine. But I prefer to use the BOARD numbering rather then BCM, How can I switch to BOARD?
I changed to BOARD, renumbered to output 12 like this:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BRORD)
GPIO.setwarnings(False)
GPIO.setup(12, GPIO.OUT)
print "LED on"
GPIO.output(12, GPIO.HIGH)
time.sleep(1)
print "LED off"
GPIO.output(12,GPIO.LOW)
Than I got a syntax error, what did I do wrong?

Thanks
Where does it tell you the error is at? By the looks of it you misspelt BOARD.
She who travels light — forgot something.

Return to “Beginners”

Who is online

Users browsing this forum: HawaiianPi and 23 guests