thatswhy26
Posts: 24
Joined: Tue Mar 10, 2015 3:10 am

What is my error?

Wed Mar 11, 2015 7:51 am

I was doing my project to light up 3 led one by one like this [url]video[/https://www.youtube.com/watch?v=41IO4Qe5Jzw] i not sure why LED does not light up and the error "in <module> GPIO.setup(7, GPIO.OUT) RuntimeError: No access to /dev/mem. Try running as root!" Why will I get this error even when I follow the guide?

Code: Select all

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)

for x in range (0,7):
GPIO.output(7,True)
time.sleep(1)
GPIO.output(7,False)
GPIO.output(11,True)
time.sleep(1)
GPIO.output(11,False)
GPIO.output(13,True)
time.sleep(1)
GPIO.output(13,False)

GPIO.cleanup()

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: What is my error?

Wed Mar 11, 2015 8:11 am

The RPi.GPIO python code requires the program to have root access. Try running the code from the command line in the following way

Code: Select all

sudo python myprogram.py
where myprogram.py is the name of your program
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

thatswhy26
Posts: 24
Joined: Tue Mar 10, 2015 3:10 am

Re: What is my error?

Wed Mar 11, 2015 8:24 am

scotty101 wrote:The RPi.GPIO python code requires the program to have root access. Try running the code from the command line in the following way

Code: Select all

sudo python myprogram.py
where myprogram.py is the name of your program
yeap thats what i do but the led is not working, but when i try other coding to light up only 1led, it works.

DirkS
Posts: 10371
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: What is my error?

Wed Mar 11, 2015 11:00 am


Return to “Python”