Kun_fu_vince
Posts: 2
Joined: Fri Dec 06, 2013 5:07 am

Need help with first project...

Fri Dec 06, 2013 6:13 am

Hey there just got a raspberry pi this week and I've spend a couple of nights frustrated trying to get a project going I started with the email notifier and I could not get it to work. So I found this project in this same forum http://www.raspberrypi.org/phpBB3/viewt ... 63&t=45931 and same thing couldn't get it to work. I'm using a cobbler and I think that it's not reading the GPIO import from the code, but I did install all the libraries I mean I don't know if I did it wrong so here it goes this is what I did.
I first created a folder using ssh.

Code: Select all

light.py
Then I used nano to write down the code and saved it

Code: Select all

nano light.py
This is the code that I got from the guy who did it already

Code: Select all

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.OUT)
GPIO.output(25, GPIO.HIGH)
time.sleep(5)
Print "code started..."
And then I made the file executable with

Code: Select all

chmod +x light.py
I then activated the scrip with

Code: Select all

sudo ./light.py
Now I'm getting and error...

Code: Select all

./light.py: 3: ./light.py: import: not found
./light.py: 4: ./light.py: import: not found
./light.py: ./light.py: syntax error: word unexpected (expecting ")")
I wanted to take a screen shot but I'm using an iPad and the size is too big for the forum... Please any help would be great I'm stuck and want to figure this out. Thanks!

gmc
Posts: 123
Joined: Fri Mar 09, 2012 11:31 am
Location: Cheshire, UK
Contact: Website

Re: Need help with first project...

Fri Dec 06, 2013 2:54 pm

A few errors there. You did not include the location of python. Add this to the first line:

Code: Select all

#!/usr/bin/python
Or else you need to run it with
sudo python light.py
Also remember its case sensitive. It should be

Code: Select all

print "code started..."

Kun_fu_vince
Posts: 2
Joined: Fri Dec 06, 2013 5:07 am

Re: Need help with first project...

Sat Dec 07, 2013 4:25 am

Ok I added those strings now I have the led fully on I mean I does not turn off what am I doing wrong?

gmc
Posts: 123
Joined: Fri Mar 09, 2012 11:31 am
Location: Cheshire, UK
Contact: Website

Re: Need help with first project...

Sat Dec 07, 2013 9:06 am

I've had a look at the original code and am not not sure why it would turn off - you haven't told it to .

Try adding this to the last line:

Code: Select all

GPIO.output(25, GPIO.LOW)

Return to “Beginners”