View previous topic :: View next topic |
Author |
Message |
tornador
Joined: 29 Jun 2014 Posts: 3 Location: France
|
Posted: Sun Jun 29, 2014 8:22 am Post subject: LCD 16*2 on i2C with Tiny85 Need help ! |
|
|
Hello,
I'm new to programming and i need help.
I need to connect a LCD on i2C bus on an AtTiny85 and a button and a led.
Every time i push the button, the led flash and a counter on LCD will show the number of times the button have been pushed.
I wrote this code who don't work:
Code: |
'Test d'un LCD 16x2 sur bus i2C avec un Tiny85.
$regfile = "attiny85.dat"
$crystal = 8000000
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
$lib "i2c.lbx" ' Utilise la librairie i2C
'$sim 'Mode simulation sans les Wait
Config Sda = Portb.0 'SDA en port 0
Config Scl = Portb.2 'SCL en port 2
Dim X As Byte 'Compteur d'appuis sur le poussoir
Config Lcdmode = Bus
Config Pinb.1 = Output
Config Pinb.5 = Input
Led Alias Pinb.1
Poussoir Alias Pinb.5
Config Lcd = 16 * 2
Display On
Cls
Lcd "test"
Lowerline
Lcd "12345678"
Do
If Poussoir = 1 Then 'If Pinb.5 = High
'***** allumer la led *****
Set Led 'ou Pinb.1 = 1
Lcd "Poussoir on"
Waitms 250 'attendre 250 ms
X = X + 1
Locate 1 , 1
Lcd X
'***** éteindre la led *****
Reset Led 'ou Pinb.1 = 0
Waitms 30 'attendre 30 ms
'Else
Pinb.5 = 0 'RAZ de la pinb.5 (ou Poussoir = 0)
End If
'***** répéter a l'infini *****
Loop
End
|
What is wrong ?
Sorry for my poor English. Thanks.
(BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.7 ) |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Jun 29, 2014 10:28 am Post subject: |
|
|
Bonjour,
A I2C LCD display is not a standard LCD so Bascom has no direct statements as "lowerline locate, cls lcd..." to drive it, you have to write it
1) you need pull up R of 10K on the SDA and SCL line.
2) Config Lcdmode = Bus it is used when you use a 8 lines data to drive the LCD, fortget it here !
3) Config Lcd = 16 * 2
Display On same as 2)
4) please send us the datasheet of the LCD without it it is impossible to explain.
5) please follow this link : http://www.mcselec.com/index.php?option=com_content&task=view&id=82&Itemid=57 a sample of I2C LCD
Bon courage
JP |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Jun 29, 2014 10:36 am Post subject: |
|
|
I just make a "Search" in the forum "I2C LCD" all terms
you could find a lot of sample following the IC driver used (actually we don't know it ! look at your data sheet)
jp |
|
Back to top |
|
|
tornador
Joined: 29 Jun 2014 Posts: 3 Location: France
|
Posted: Sun Jun 29, 2014 12:22 pm Post subject: |
|
|
Hello,
Merci pour votre aide.
I don't have the datasheet. It's a noname LCD on Ebay. Here is the description:
[img]
[/img]
I have the 2 resistors 10K attached on my circuit on SDA and SCL and other side to +5V
This LCD works great on an Arduino UNO on i2C bus.
I try a few of the links on the seach tab (3036 results !) but hard to understand. I will continue to see if i find something who fit my needs.
P.S. Your 4 books are greats Mr Duval. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Jun 29, 2014 3:11 pm Post subject: |
|
|
bonjour,
Sorry for other bascom users, but in this case is only French to French discussion about AN 118.
Ce LCD est un très classique LCD 2 lignes monté sur un adaptateur qui transforme les signaux I2C en signaux compatibles avec le circuit hd44780 ou équivalent qui pilote le LCD.
le problème est de connaitre les signaux.
je suppose que l'auteur du shied I2C-LCD a utilisé un µC qui fait ce boulot ou et ce serais parfait un PCF8574 (lire sur le shield)
voir la librairie liquidCrystal dans le répertoire Libraries de Arduino
un gros travail pour tout traduire en Basic Bascom.
l'AN 118 montre l'utilisation du PCF8574 un grand classique qui convertit les signaux I2C sur 8 lignes, l'auteur donne aussi une lib permettant de l'utiliser et un super exemple , avec cette lib l'auteur utilise les même commandes que le Basic Bascom.
SVP tiens nous au courant !
bon courage
JP
|
|
Back to top |
|
|
tornador
Joined: 29 Jun 2014 Posts: 3 Location: France
|
Posted: Sun Jun 29, 2014 7:08 pm Post subject: |
|
|
Bonsoir,
Merci pour le Français, cela va etre plus facile pour moi !
Bon, le circuit du shield est un PCF8574T.
J'ai essayé la lib de l'AN 118, chargé son exemple dans mon Tiny85 (j'ai remplacé Config Scl = Portd.6 et Config Sda = Portd.7 par
Config Scl = Portb.2 et Config Sda = Portb.0 pour correspondre aux broches du Tiny)
Rien ne s'affiche sur le LCD. Rien non plus en mode simulation.
J'y renonce pour ce soir !
Bien cordialement. |
|
Back to top |
|
|
|