Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

send data from serial port to microcontroller 16f877a and display to lcd

Status
Not open for further replies.

aldwinsumalabe

New Member
please help

data send from pc to pic can loop back and display to pc again. i want to capture the data from microcontronller and assign to a variable and display to lcd. if i send from pc , microcontroller respond that data is receive.

.tnx

Code:
 program testlcd1    
 

 'dim msg as string
 'UART1_DATA_READY as byte
       ' Lcd module connections
dim LCD_RS as sbit at RB4_bit
    LCD_EN as sbit at RB5_bit
    LCD_D4 as sbit at RB0_bit
    LCD_D5 as sbit at RB1_bit
    LCD_D6 as sbit at RB2_bit
    LCD_D7 as sbit at RB3_bit


    LCD_RS_Direction as sbit at TRISB4_bit
    LCD_EN_Direction as sbit at TRISB5_bit
    LCD_D4_Direction as sbit at TRISB0_bit
    LCD_D5_Direction as sbit at TRISB1_bit
    LCD_D6_Direction as sbit at TRISB2_bit
    LCD_D7_Direction as sbit at TRISB3_bit
    dim i as byte

  sub procedure display1()   'to display text

  Lcd_Out(1,3,"Serial port ")
  delay_ms(500)
   Lcd_Cmd(_LCD_CLEAR)
  Lcd_Out(1,3,"Good luck kk")


delay_ms(500)
 Lcd_Cmd(_LCD_CLEAR)

end sub
  ' to active library




dim receive as byte
'delimiter as string[10]
 dim Attempts as byte
  dim data_ as byte
 dim  Output as string[50]
 dim txt1 as char[16]
   dim uart_rd as byte
   dim aldw as word
main:

  adcon1=0x02
trisb=%00000000
portb=%00000000
trisa=%00000011
'porta=%00000000
Lcd_init()
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_LCD_CURSOR_OFF)
  'serial port
  UART1_Init(9600)                     ' Initialize UART module at 9600 bps
  Delay_ms(100)                        ' Wait for UART module to stabilize

  UART1_Write_Text("connected to pc")

 UART1_Write(10)                      ' Line Feed
  UART1_Write(13)                      ' Carriage Return

  while (TRUE)
                         ' Endless loop
    if (UART1_Data_Ready() <> 0) then  ' If data is received,
      uart_rd = UART1_Read()
     UART1_Write(uart_rd)
     receive=UART1_Read()
      'output=word(UART1_Read())
        'UART1_Write_Text(output)
           data_=0x1E
           UART1_Write(data_)
          ' UART1_Write_Text(UART1_Write(data_))
            delay_ms(1000)
          Lcd_Out(2,1,"Message receive")
            Lcd_Out(1,1,output)  'dummy variable Output , i want to display the receive data from pc  to lcd
               delay_ms(4000)
          else
              Lcd_Cmd(_LCD_CLEAR)
                    delay_ms(1000)
          'Lcd_Out(2,3,"Waiting")
                display1()
                      delay_ms(1000)
    'end if
     end if


  wend


end.
 
Status
Not open for further replies.

Latest threads

Back
Top