Relay Driver Controlled by Serial using 16F877A

Discussion in 'Embedded Systems and Microcontrollers' started by karloz34, Oct 6, 2015.

  1. karloz34

    Thread Starter New Member

    Oct 6, 2015
    Hello community,

    I'm attempting to implement a serial controlled relay driver using a PIC16F877A uC.

    My circuit can be described in the next manner: A +12v input, a LM7805 for a net of +5v, a MAX232 for TTL signal conversion, PIC16F877A for serial communication and controlling the output port on which eight relays will be controlled. Each relay will power up a +12v strobe light at a time.

    I have the schematic done but I'm struggling with the programming of the PIC, I have read several tutorials on using USART for serial communication an I have the following code:

    Let's take a look at the main loop:

    Will this set RB0 to high when the string at rcbuff is relay1?

    Any easier way of setting this up?

    Thanks, any help will be greatly appreciated.
  2. dannyf

    Well-Known Member

    Sep 13, 2015
    Code (Text):
    1. if (rcbuf == "relay1")
    Learning some C would be helpful for you.
  3. JohnInTX


    Jun 26, 2012
    C will not compare strings directly. Use strcmp or strncmp which you will find in the libraries. These are described in Appendix A of the XC8 compiler User's Guide. You'll have to include string.h to use them.

    Good luck.
    Last edited: Oct 7, 2015