Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Arduino Nano with I2c LCD and backlight
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Apr 12, 2017 11:39 am    Post subject: I2c lcd working Reply with quote

Well done!! The original library was written by Kent and worked also on 20x4 display with two E connections.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Tue Sep 05, 2017 10:36 am    Post subject: Reply with quote

One day brings me idea that this horse can walk/trot thru display lenght Very Happy
I wrote some function for that and horse "reveals the inscription" you want...

Check short 17sec video

https://drive.google.com/open?id=0ByTGnTHgAjlzQ1VFTUFxd0VHSG8

I break my work on something to check if this could be done. Simply for fun Very Happy
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Wed Sep 06, 2017 10:02 am    Post subject: Reply with quote

Nice demo. still amazed by the fact that this is just a normal text display.
Video is great, now we wait for the code Smile

_________________
Mark
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 971

poland.gif
PostPosted: Wed Sep 06, 2017 10:19 am    Post subject: Reply with quote

Please take in account that Helpb ismy favoured multipurpose variable like Helpstr is my "always use" String variable so they are not included in this INC file.
This effect simply can be included into any project simply by :
Code:
 $include "splash_horse.inc"
  Call Splash_screen()


Inc file lower Wink Im a little bit shame about no optimisation but this is done once at reboot. Maybe someone can do better Very Happy This wasmade for fun.

Code:
$nocompile

 Dim Shag As Byte , Lcd_pos As Byte
 Dim Logo1 As String * 16 , Logo2 As String * 16 , Logo_done As Byte

 Logo1 = "Rejestrator" : Logo2 = "by Wally"

'-------------------------------------------------------------------------------

Sub Horse1
Deflcdchar 0 , 32 , 32 , 32 , 32 , 3 , 7 , 14 , 14
Deflcdchar 1 , 32 , 32 , 32 , 32 , 15 , 31 , 31 , 31
Deflcdchar 2 , 32 , 32 , 32 , 32 , 3 , 31 , 31 , 31
Deflcdchar 3 , 32 , 1 , 31 , 31 , 31 , 27 , 19 , 16
Deflcdchar 4 , 12 , 24 , 16 , 1 , 1 , 1 , 32 , 32
Deflcdchar 5 , 31 , 31 , 30 , 23 , 32 , 32 , 16 , 32
Deflcdchar 6 , 31 , 31 , 3 , 2 , 18 , 2 , 1 , 32
Deflcdchar 7 , 28 , 28 , 4 , 4 , 8 , 32 , 32 , 32
End Sub


Sub Horse2
Deflcdchar 0 , 32 , 32 , 32 , 32 , 32 , 7 , 15 , 30
Deflcdchar 1 , 32 , 32 , 32 , 32 , 14 , 31 , 31 , 31
Deflcdchar 2 , 32 , 32 , 32 , 32 , 7 , 31 , 31 , 31
Deflcdchar 3 , 32 , 2 , 31 , 31 , 31 , 27 , 19 , 16
Deflcdchar 4 , 16 , 32 , 32 , 1 , 1 , 1 , 32 , 32
Deflcdchar 5 , 31 , 31 , 27 , 18 , 1 , 1 , 17 , 32
Deflcdchar 6 , 31 , 31 , 1 , 1 , 1 , 1 , 32 , 32
Deflcdchar 7 , 24 , 28 , 4 , 8 , 16 , 32 , 16 , 32
End Sub

Sub Horse3
Deflcdchar 0 , 32 , 32 , 32 , 7 , 15 , 14 , 28 , 24
Deflcdchar 1 , 32 , 32 , 32 , 15 , 31 , 31 , 31 , 31
Deflcdchar 2 , 32 , 32 , 32 , 3 , 31 , 31 , 31 , 31
Deflcdchar 3 , 1 , 31 , 31 , 31 , 27 , 27 , 16 , 16
Deflcdchar 4 , 19 , 19 , 2 , 2 , 4 , 32 , 32 , 32
Deflcdchar 5 , 31 , 7 , 14 , 6 , 1 , 32 , 32 , 32
Deflcdchar 6 , 15 , 7 , 19 , 15 , 32 , 16 , 32 , 32
Deflcdchar 7 , 16 , 24 , 12 , 4 , 2 , 1 , 32 , 32
End Sub

Sub Lcd_pictur

 Incr Lcd_pos
  If Lcd_pos > 21 Then
   Logo_done = 1 : Cls : Exit Sub
  End If

 Helpb = Lcd_pos - 4


   If Lcd_pos < 6 Then

    Locate 1 , 1

    Select Case Lcd_pos
     Case 1
       Lcd Chr(3)
     Case 2
       Lcd Chr(2) ; Chr(3)
     Case 3
       Lcd Chr(1) ; Chr(2) ; Chr(3)
     Case 4
       Lcd Chr(0) ; Chr(1) ; Chr(2) ; Chr(3)
     Case 5
       Lcd Chr(32) ; Chr(0) ; Chr(1) ; Chr(2) ; Chr(3)
    End Select

   Else
    Locate 1 , Helpb
     Lcd Chr(32) ; Chr(0) ; Chr(1) ; Chr(2) ; Chr(3)

     If Helpb > 3 Then
      Pomoc = Helpb - 3
      Helpstr = Mid(logo1 , 1 , Pomoc)
      Locate 1 , 3 : Lcd Helpstr
     End If

   End If



   If Lcd_pos < 6 Then

    Locate 2 , 1

    Select Case Lcd_pos
     Case 1
       Lcd Chr(7)
     Case 2
       Lcd Chr(6) ; Chr(7)
     Case 3
       Lcd Chr(5) ; Chr(6) ; Chr(7)
     Case 4
       Lcd Chr(4) ; Chr(5) ; Chr(6) ; Chr(7)
     Case 5
       Lcd Chr(32) ; Chr(4) ; Chr(5) ; Chr(6) ; Chr(7)
    End Select

   Else
    Locate 2 , Helpb
     Lcd Chr(32) ; Chr(4) ; Chr(5) ; Chr(6) ; Chr(7)

     If Helpb > 4 Then
      Pomoc = Helpb - 4
      Helpstr = Mid(logo2 , 1 , Pomoc)
      Locate 2 , 4 : Lcd Helpstr
     End If



   End If

  Waitms 125

End Sub

Sub Splash_screen

   Do
    Call Horse1
     Call Lcd_pictur
    Call Horse2
     Call Lcd_pictur
    Call Horse3
     Call Lcd_pictur
   Loop Until Logo_done = 1

End Sub
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Wed Sep 06, 2017 10:49 am    Post subject: Reply with quote

Thanks, i appreciate it. Very Happy
_________________
Mark
Back to top
View user's profile Visit poster's website
tomik

Bascom Member



Joined: 15 Sep 2014
Posts: 5

slovenia.gif
PostPosted: Wed Dec 25, 2019 11:09 pm    Post subject: Reply with quote

Hello
I'm trying to use the library to control the LCD via the I2C forum post, $ lib "bl_Lcd_i2c.lib". I have a YwRobot module. I think the LCD is ok and everything works. Also, the library seems ok?
But when the loop is executed for the first time I get the correct values, the next time the loop is executed, the output is strange.

I notice that displaying values on lcd is very dependent on the value of the I2cdelay constant. To display the values as shown in the figures (in attachment), the value of the I2cdelay constant was 12. What does this constant actually mean in this I2C communication?

I tested with pull-up resistors of 4.7k and 10k.

What could be wrong?

I also tried with $ lib "YwRobot_Lcd_i2c.lib" but the result is very similar.

The code in the attachment...

Rolling Eyes
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5920
Location: Holland

blank.gif
PostPosted: Sat Dec 28, 2019 1:49 pm    Post subject: Reply with quote

the i2cdelay constant is only for soft I2C. But you use TWI : $lib "i2c_twi.lbx" ' we do not use software emulated I2C but the TWI 'bit rate register

So this constant should not play any role.

Make sure the processor is running the speed you think it does.

you have : $crystal = 16000000
so test if that is really the speed.

when the code shows ok the first loop, i see no reason why it would mess up the next loop.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum