Raspberry Pi-Python-rpi.gpio

bkibalo
Posts: 9
Joined: Thu May 09, 2013 1:39 pm
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by bkibalo »

WMc,

Assuming you've called idle correctly - you should be able to get this working just calling the function.
Make sure you are in the directory where the .py files are.

Type -- "sudo idle" at the prompt

>>> from set_LED import *

You shouldn't get any errors, idle should just return you another prompt >>>

>>> set_LED('red','on')

You should see the red LED turn on

>>> set_LED('green','on')

You should see the green LED turn on. Try on/off to your satisfaction. The use of quotes and the proper spelling and capitalization (all lowercase) of the words is important here. This is the simplest implementation of this module - if this isn't working, something else is wrong. I would be interested in seeing exactly how you are loading idle and what commands you are typing. If you have just been calling python until now, use idle to troubleshoot the issue and get back to me.

We will get this working!

Thanks
Ben
User avatar
WMc
Posts: 15
Joined: Sat Dec 10, 2011 3:46 pm
Location: Central FL
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by WMc »

@Ben
'
I have typed everything as you posted above.
'
"sudo idle"
then a Python pop-up window opens
>>> from set_LED import *
'
Now I get a " ImportError: No module named set_LED "
'
I have noticed that the properties of IDLE say Python 2.7.4.tgz but the pop-up window shows 2.7.3rc2...I haven't read enough into Linux or Python to recognize the file extensions. Is this just a glitch or a problem?
using "dir"in the LXterm. shows RPi.GPIO and led.py in the Python 2.7.4 folder.
'
Is there a way to take a screen shot with the RPi?
'
Thanks for hanging with me on this matter, I really appreciate it.
__Walt McDonald__


It's not rocket-surgery
I see why we don't have any water,All of the pipes are full of wires!
E=WMc2
Now with WiFi



ABB M202 certified
ABB M211 certified
bkibalo
Posts: 9
Joined: Thu May 09, 2013 1:39 pm
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by bkibalo »

WMc,

Sounds like you may have an issue with the path settings on your Pi. Not sure why this is - before we make that conclusion, make sure you are in the directory where the project files are. For example, if you type 'ls' you should see set_LED.py, get_temp.py, etc...

If that is the case then we need to append your path environment for python. make sure you are in the folder with all the files and type 'pwd' (stands for print working directory). You should see something like /home/pi/something/nutsandvolts/

Open up idle

Type
>>> import sys
<should see no errors>
>>> sys.path.append('/home/pi/something/nutsandvolts')
<should see no errors>
>>> from set_LED import *
<should see no errors>

With the path append we have added a pointer to your folder with all the stuff that needs to be imported. This should work. As for a screen shot, try doing a google search, you may have to install some program.

You could try " sudo idle >> capture.txt "

That will redirect output of your command to the capture.txt file, but I don't know if all the python goods will go there or just the command-line (shell) output. Worth a try anyhow.

Ben
User avatar
WMc
Posts: 15
Joined: Sat Dec 10, 2011 3:46 pm
Location: Central FL
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by WMc »

@Ben
'
I hate to sound dismal, But this isn't working either.
'
I think the SD Card is corrupt. When the PI boots up, I see a lot of files ignored because of errors.
'
I'm gonna order another SD Card with the RaspberryPi O.S. on it and see what happens.
'
Thanks for all the help...I'll report back when I get the new SD Card.
'
P.S. Great article.
__Walt McDonald__


It's not rocket-surgery
I see why we don't have any water,All of the pipes are full of wires!
E=WMc2
Now with WiFi



ABB M202 certified
ABB M211 certified
User avatar
WMc
Posts: 15
Joined: Sat Dec 10, 2011 3:46 pm
Location: Central FL
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by WMc »

@Ben & Jerry
'
Sorry for the long delay.
'
I got the new SD card and I had the same problem. I then used "sudo apt-get updates; sudo apt-get upgrades". This took
about 30 mins to complete, But it helped to get me going. It also freed-up about 13.5 MB of card space...cool.
'
I'm now using Python3 with RPi.GPIO and the little app. "led.py" and it works great. The editor is better too. A simple "sudo python3" works.
'
Thanks for the help and support...I'm up and running now. "WooHoo"!!!
'
Now I'm off to try out the MAXIM 18B20.
'
Thanks again.
'
PS the "def" stuff needs to be inside an " ' " (asterisk's) like... " if 'color' == 'red': " ___not>__ " if color == 'red' "
__Walt McDonald__


It's not rocket-surgery
I see why we don't have any water,All of the pipes are full of wires!
E=WMc2
Now with WiFi



ABB M202 certified
ABB M211 certified
bkibalo
Posts: 9
Joined: Thu May 09, 2013 1:39 pm
Contact:

Re: Raspberry Pi-Python-rpi.gpio

Post by bkibalo »

WMc

I'm glad you are making progress!

Keep us posted. Once you get in the swing of this, I think you will realize there are a lot more possibilities.

BTW - python3 should work fine, but I was using python 2 (not sure what subversion, maybe 7?) to run all of that code. If you start having weird errors again, try running just normal python (not python3).

Ben
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests