Hallo

Probeer nu al een tijdje een keypad en lcd werkend te krijgen in real pic simulator.(pic16F877a)
Maar wat ik ook probeer krijg niet meer dan 4 cijfers c.q. leters te zien op lcd.
graag wat hulp hierbij.
de hex file lijkt goed tezijn.
hier is de code.( krijg hem niet op de gebruikelijke manier ingevoegd.)


program LCD_4bit

dim
  LCD_RS as sbit at RA0_bit
  LCD_EN as sbit at RA1_bit
  LCD_D7 as sbit at RB7_bit
  LCD_D6 as sbit at RB6_bit
  LCD_D5 as sbit at RB5_bit
  LCD_D4 as sbit at RB4_bit
  LCD_D3 as sbit at RB3_bit
  LCD_D2 as sbit at RB2_bit
  LCD_D1 as sbit at RB1_bit
  LCD_D0 as sbit at RB0_bit

dim
  LCD_RS_Direction as sbit at TRISA0_bit
  LCD_EN_Direction as sbit at TRISA1_bit
  LCD_D7_Direction as sbit at TRISB7_bit
  LCD_D6_Direction as sbit at TRISB6_bit
  LCD_D5_Direction as sbit at TRISB5_bit
  LCD_D4_Direction as sbit at TRISB4_bit
  LCD_D3_Direction as sbit at TRISB3_bit
  LCD_D2_Direction as sbit at TRISB2_bit
  LCD_D1_Direction as sbit at TRISB1_bit
  LCD_D0_Direction as sbit at TRISB0_bit


dim msg as String[16]             ' String I used in Welcome Screen and Conversion
dim ss as byte                  ' Seconds Counter
dim mm as byte                  ' Minutes Counter
dim hh as byte                  ' Hours Counter



sub procedure print_time()
' A procedure that prints the time to the LCD
  ' Converting hours to string and print it
  ByteToStr(hh, msg)
  Lcd_Chr(2, 5, msg[1])
  Lcd_Chr(2, 6, msg[2])

  ' Converting minutes to string and print it
  ByteToStr(mm, msg)
  Lcd_Chr(2, 8, msg[1])
  Lcd_Chr(2, 9, msg[2])

  ' Converting seconds to string and print it
  ByteToStr(ss, msg)
  Lcd_Chr(2, 11, msg[1])
  Lcd_Chr(2, 12, msg[2])
end sub

sub procedure increment_hours()
' A procedure that increments time by one hour
  hh = hh + 1
  if hh = 24 then
     hh = 0
  end if
end sub

sub procedure increment_minutes()
' A procedure that increments time by one minute
  mm = mm + 1
  ' If minutes = 60 .. increment one hour
  if mm = 60 then
    mm = 0
    increment_hours()
  end if
end sub

sub procedure increment_seconds()
' A procedure that increments time by one second
  ' Increment Seconds Counter
  ss = ss + 1
  ' If seconds = 60 .. increment one minute
  if ss = 60 then
    ss = 0
    increment_minutes()
  end if
end sub

sub procedure print_msg()
  dim i as byte
  for i = 0 to 9
    Lcd_Chr(1, i + 1, msg[i])   ' Print Character
    Delay_MS(150)               ' Delay between each keyStroke :P
  next i
end sub



main:
Lcd_Init()
Delay_MS(1000)
Lcd_Cmd(_LCD_CURSOR_OFF)


  ss = 0                        ' Intialize the seconds counter
  mm = 0                        ' Intialize the minutes counter
  hh = 0                        ' Intialize the hours counter

  ' Print Welcome Screen
  ' Message Maximum Length = 10 Characters
  msg = "Hi, Hallo"            ' My Hello Message
  print_msg()                   ' Print Message

while TRUE
  ' Clear Screen and Continue the Clock
  Lcd_Cmd(_Lcd_Clear)
  Lcd_Chr(2, 7, ":")
  Lcd_Chr(2, 10, ":")
  print_time()
  wend

end

[Bericht gewijzigd door Henry S. op (0%)]