Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

PIC with module BT RN4678

Home Forums MikroC Pro for PIC Project Discussions PIC with module BT RN4678

This topic contains 1 reply, has 2 voices, and was last updated by  Bitahwa Bindu 8 months, 2 weeks ago.

  • Author
    Posts
  • #3014

    lorenrus
    Participant

    I’m using PIC-18f4520, i want to switch on my led in position RB7. I checked with the oscilloscope that the bits arrive at the RX pin of the PIC. I have connected the TX pin of BT to the RX pin of the PIC. But when I give the command on the phone I do not turn on the LED.

    I don’t have the schematic in Proteus, I’ll text it really.

    My code :

     

    char x;

    void main()
    {
    OSCCON = 0x76;

    TRISC.B7 = 1; // RX
    TRISC.B6 = 0; // TX

    TRISB.B7 = 0; // My led

    // BT configuration

    TRISB.B6 = 0; // SW_BTN
    TRISB.B5 = 0; // WAKE UP
    TRISB.B4 = 0; // EAN
    TRISB.B3 = 0; // P2_0
    TRISB.B2 = 0; // P2_4

    UART1_Init(115200); // Baud rate

    while(1)
    {

    if (UART1_Data_Ready () == 1)// text if the data is ready to be read
    {

    x = UART1_Read ();

    }

    if(x == ‘C’)
    {
    LATB.B7 = 1;
    }
    if(x == ‘A’)
    {
    LATB.B7 = 0;
    }

     

    }

    }

    • This topic was modified 8 months, 2 weeks ago by  lorenrus.
    • This topic was modified 8 months, 2 weeks ago by  lorenrus.
    • This topic was modified 8 months, 2 weeks ago by  lorenrus.
    • This topic was modified 8 months, 2 weeks ago by  lorenrus.
  • #3019

    Bitahwa Bindu
    Keymaster

    How are you checking your code? Are you using hardware or simulation? You said you checked with oscilloscope that the bit arrives at RX of PIC? what bit arrives? is the baud rate you are transmitting with the same as the baud rate of your PIC? if the baud rate is different you might receive some bit on RX but wrong bit and if that bit is not ‘C’ you won’t switch ON your LED.

You must be logged in to reply to this topic.

Select your currency
EUR Euro
USD United States (US) dollar