nautilus27
Posts: 82
Joined: Fri May 22, 2015 9:38 pm

Webiopi script throws GPIO error

Sat Sep 17, 2016 6:10 pm

Hi guys,

I'm building myself a rover. So today I installed Webiopi to my Raspberry Pi 3 using instructions on this page: https://github.com/doublebind/raspi

Then I did write some code from this example: https://issuu.com/themagpi/docs/issue_9 ... 23/2587746

Code: Select all

import webiopi
GPIO = webiopi.GPIO

L1=17
L2=18
R1=22
R2=23

def turn_right ():    
	GPIO.output(L1,GPIO.LOW)
	GPIO.output(L2,GPIO.HIGH)
	GPIO.output(R1,GPIO.HIGH)
	GPIO.output(R2,GPIO.LOW)

def turn_left ():
	GPIO.output(L1,GPIO.HIGH)
	GPIO.output(L2,GPIO.LOW)
	GPIO.output(R1,GPIO.LOW)
	GPIO.output(R2,GPIO.HIGH)

def forward():
	GPIO.output(L1,GPIO.LOW)
	GPIO.output(L2,GPIO.HIGH)
	GPIO.output(R1,GPIO.LOW)
	GPIO.output(R2,GPIO.HIGH)

def backward():
	GPIO.output(L1,GPIO.HIGH)
	GPIO.output(L2,GPIO.LOW)
	GPIO.output(R1,GPIO.HIGH)
	GPIO.output(R2,GPIO.LOW)

GPIO.setFunction(L1, GPIO.OUT)
GPIO.setFunction(L2, GPIO.OUT)
GPIO.setFunction(R1, GPIO.OUT)
GPIO.setFunction(R2, GPIO.OUT)

server.addMacro(turn_right)
server.addMacro(turn_left)
server.addMacro(forward)
server.addMacro(backward)


server = webiopi.Server(
	    port=8000,
	    login="cambot",
	    password="cambot")

webiopi.runLoop()

server.stop()
But I'm getting this error when I try to run it:

Code: Select all

Traceback (most recent call last):
  File "rover.py", line 2, in <module>
    GPIO = webiopi.GPIO
AttributeError: 'module' object has no attribute 'GPIO'

pcmanbob
Posts: 9004
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Webiopi script throws GPIO error

Mon Sep 19, 2016 10:48 am

Hi.

you may stand a better change of finding an answer if you asked on the Webiopi forum

https://groups.google.com/forum/#!forum/webiopi
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

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

Re: Webiopi script throws GPIO error

Mon Sep 19, 2016 11:13 am

Someone has already asked that question

https://groups.google.com/forum/#!topic ... p-9WvtcUUo
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Python”