1

Raspberry Pi for Dummies. Page 49

Line 7 GPIO.setmode(GPIO.BCM)

error: NameError: name GPIO is not defined

we've checked it's definately the letter 'O' not a zero. Either the code isn't right or the import RPi.GPIO isn't correct.

`we tried python and python3

Any ideas?

  • Post the code you are attempting to run together with the actual error message (cut & paste). – joan Jan 10 '17 at 14:00
  • 1
    Hi Jack :) Welcome to Pi Q&A - Technically - If one of the answers, answered your question - you should have up voted it and accepted it (I understand you may not have had enough rep to accept it - I don't get that but yea) Please accept an answer if you can.. and don't be shy with up votes :D Good luck and see you around. – Piotr Kula Jan 10 '17 at 14:27
1

I am not sure what the full example looks like but ti should look like this.

#external module imports
import RPi.GPIO as GPIO

#pin setup
GPIO.setmode(GPIO.BCM)
  • the issue was as GPIO missing. Thanks, it works now! – Jack Jan 10 '17 at 14:11
0

You are not providing all your code, so I'm not sure what you have imported, however, after doing

import RPi.GPIO as GPIO

the statement

GPIO.setmode(GPIO.BCM)

should work. If you forgot the as GPIO part, it would still work but you'd have to type

RPi.GPIO.setmode(RPi.GPIO.BCM)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.