Hi, folks! Being new to the Pi, I thought it'd be a good idea to get my hands dirty with a little project here, so, I got the 16x2 LCD kit, and a cobbler, and just jumped right in!... All went well until I tried to run the Adafruit_CharLCD.py sample program.... My first inclination was to run it from a command-line, since I was already there doing all the other "sudo" stuff... and I get this nasty-gram from the Pi:
File"./Adafruit_CharLCD.py", line 60
If not GPIO:
IndentationError: expected an indented block
So have I gotten hold of a bad version of this program somehow?
Thanks for any light you guys/gals can shed on this one!!
JoeP
Syntax error in Adafruit_CharLCD.py??
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
-
- Posts: 466
- Joined: Thu Aug 30, 2012 1:34 am
Re: Syntax error in Adafruit_CharLCD.py??
congratulations. you have discovered the single most annoying feature of python. by staring at your keyboard wrong and accidentally adding or deleting a space at the beginning of a line you can render your code unusable.
check to make sure the code is indented correctly. note that this error is in the library, not in the file you are trying to run.
the code in the general vicinity of your error should look like this...
check to make sure the code is indented correctly. note that this error is in the library, not in the file you are trying to run.
the code in the general vicinity of your error should look like this...
Code: Select all
def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO = None):
# Emulate the old behavior of using RPi.GPIO if we haven't been given
# an explicit GPIO interface to use
if not GPIO:
import RPi.GPIO as GPIO
self.GPIO = GPIO
-
- Posts: 466
- Joined: Thu Aug 30, 2012 1:34 am
Re: Syntax error in Adafruit_CharLCD.py??
oops. i guess it's possible that the library is the code you were trying to run.
anyway... check the indentation.
anyway... check the indentation.
-
- Posts: 14
- Joined: Wed Jan 16, 2013 5:25 pm
Re: Syntax error in Adafruit_CharLCD.py??
Thanks for the reply! What I'm trying to run is the Adafruit_CharLCD.py sample mentioned in the tutorial for the Adafruit 16x2 LCD, to be gotten from GITHUB... followed the instructions in the tutorial, and the error message was the result... I'm certainly not above beating my way through the code shoving things around to deal with this, but a) shouldn't the samples be reasonably @ready to run@?, and b), how to know what the author intended the indentation to be?
Here's the code in the area you mentioned.....
Now it's complaining about another section further down... I'm not sure what the author intended.....
Thanks again for any light you can shed on this (so far) rather murky subject!
Joep
Here's the code in the area you mentioned.....
Code: Select all
def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO = None):
# Emulate the old behavior of using RPi.GPIO if we haven't been given
# an explicit GPIO interface to use
if not GPIO:
import RPi.GPIO as GPIO
self.GPIO = GPIO
self.pin_rs = pin_rs
self.pin_e = pin_e
self.pins_db = pins_db
self.GPIO.setmode(GPIO.BCM)
self.GPIO.setup(self.pin_e, GPIO.OUT)
self.GPIO.setup(self.pin_rs, GPIO.OUT)
Thanks again for any light you can shed on this (so far) rather murky subject!
Joep
- txbobs
- Posts: 22
- Joined: Wed Jan 30, 2013 3:11 pm
Re: Syntax error in Adafruit_CharLCD.py??
I went through the tutorial last night and the code I downloaded worked fine.
http://learn.adafruit.com/adafruit-16x2 ... spberry-pi
Did you get the code from the same place?
http://learn.adafruit.com/adafruit-16x2 ... spberry-pi
Did you get the code from the same place?
-
- Posts: 14
- Joined: Wed Jan 16, 2013 5:25 pm
Re: Syntax error in Adafruit_CharLCD.py??
Hi again! Sorry to have been so tardy in responding - Went thru the download process a few days later, and all seems to work as advertised.... Guess I must have botched something somewhere along the way... On to other challenges!
JoeP
JoeP
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/