syed-anwar
Posts: 38
Joined: Fri Apr 15, 2016 3:39 am

button interfacing

Thu Jul 21, 2016 6:35 am

hi
i am going to interface the button with raspi model b the code is
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

but it give me the following error
attribute error: module object has no attribute setmode
what the problem is and how to solve it please?

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: button interfacing

Thu Jul 21, 2016 7:29 am

Make sure that none of your own modules are called RPi.GPIO

... otherwise, that name will get imported instead of the PI version...

There is nothing wrong with your syntax... so the problem has to be a naming problem.

marcus
marcus
:ugeek:

syed-anwar
Posts: 38
Joined: Fri Apr 15, 2016 3:39 am

Re: button interfacing

Thu Jul 21, 2016 9:03 am

ok thanks

User avatar
B.Goode
Posts: 8034
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: button interfacing

Thu Jul 21, 2016 9:07 am

MarkHaysHarris777 wrote: There is nothing wrong with your syntax... so the problem has to be a naming problem.
Or a VERY old version of the RPi.GPIO library that goes back several years before the developer implemented the setmode function.

Return to “General discussion”