li16
Posts: 6
Joined: Sat Nov 10, 2018 11:02 am

Defining GPIO to LCD mapping

Sat Nov 10, 2018 7:27 pm

So ive this lcd interfacing with the raspberry pi GPIO pins in the circuit and in the code when defining GPIO to LCD mapping:

Code: Select all

lcd_rs        = 21 
lcd_en        = 20
lcd_d4        = 16
lcd_d5        = 12
lcd_d6        = 5
lcd_d7        = 25
I was wondering why the pins written in the code for d4, d5, and d6 dont match the circuit? And rs,en, and d7 match. Im not exactly sure what is going on. Your help would be appreciated!
Last edited by li16 on Fri Nov 23, 2018 11:59 am, edited 1 time in total.

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

Re: Defining GPIO to LCD mapping

Sat Nov 10, 2018 9:52 pm

From the snippets of information you have given its hard to say.

It might help if you told us were you got the diagram from and if the code is from the same place ?

The LCD in the diagram seems to to be connected to devices RN1 & RN2 and not directly to the
Pi gpio so what are they ?
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

Andyroo
Posts: 1042
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Defining GPIO to LCD mapping

Sat Nov 10, 2018 10:09 pm

Pin out on the LCD reminds me of a HD44780 but not seen one documenting the pull ups like that...
Need Pi spray - these things are breeding in my house...

li16
Posts: 6
Joined: Sat Nov 10, 2018 11:02 am

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 10:25 am

There are 2 resistor arrays, would that effect?

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

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 12:44 pm

We ask questions because we can't see your pi or what's connected to it, for example by posting just those few lines of code we have no idea if they are bcm numbers, or board numbers or in fact if you are even using RPi.GPIO or some thing else, nor do we know what display you are using.

As always the more information you can provide the better chance you have of getting a meaning full answer.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

li16
Posts: 6
Joined: Sat Nov 10, 2018 11:02 am

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 2:18 pm

Alright, I'm going to try to be more thorough with my explanation. So the raspberry Pi is receiving the data from the bluetooth module. Depending on the data it receives, a certain message is being spoken from speaker. The code and circuit above are from the same place and everything is working but im trying to understand some bits of the code because im stuck.
the first question was about why some data pins don't match the GPIO pins?
Last edited by li16 on Fri Nov 23, 2018 12:00 pm, edited 1 time in total.

B.Goode
Posts: 6652
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 2:47 pm

. The code and circuit above are from the same place and everything is working

If it is working why worry?

But if you need to understand, I'd suggest contacting the author or other source of your information.

(I don't understand either, it looks like a mistake to me. But if it works I must be wrong, so you shouldn't rely on my opinion... )

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

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 4:12 pm

Well it looks like the diagram has D4 & D5 moved up one gpio, but D6 is totally on the wrong gpio.

So if its working did you build it or was it some thing pre built ?

if it was pre built then have a look at the wiring to see if the connections for D4,D5 & D6 are actually on the correct gpio pins.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

li16
Posts: 6
Joined: Sat Nov 10, 2018 11:02 am

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 4:17 pm

So the pins in the code and in the circuit are supposed to match? Its not correct to have them not matching?
Last edited by li16 on Fri Nov 23, 2018 12:01 pm, edited 1 time in total.

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

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 4:32 pm

li16 wrote:
Sun Nov 11, 2018 4:17 pm
Yeah it was pre built
So the pins in the code and in the circuit are supposed to match? Its not correct to have them not matching?
yes the pins in the code should match the connections shown in the diagram , I suspect the actual wiring matches the code and the diagram is wrong. ( because it works )
And also concerning the questions i left as comments in the code, could you please help me with those
If you want help with understanding the code the best person to ask is the author , he/she will/should understand it and be able to explain and answer any questions you have.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

li16
Posts: 6
Joined: Sat Nov 10, 2018 11:02 am

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 5:07 pm

Inside the try statement, then when we get to err==1 is it comparing 0 and 1 to give false? If so does it take us to the except block to execute the exception?
Last edited by li16 on Fri Nov 23, 2018 12:01 pm, edited 1 time in total.

B.Goode
Posts: 6652
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Defining GPIO to LCD mapping

Sun Nov 11, 2018 8:31 pm

li16 wrote:
Sun Nov 11, 2018 5:07 pm
In python if we have:
if (string == "1a") and err==0:
print "thank you",string
espeak.synth("thank you")
lcd.message(' thank you')
t1 = datetime.now()
err==1

Inside the try statement, then when we get to err==1 is it comparing 0 and 1 to give false? If so does it take us to the except block to execute the exception?

I think you need to do some reading about what an Exception is in Python, when they occur and how they are handled. I don't think using a variable name that in English looks like an abbreviation for error has any relevance.

Return to “Python”