[Help] PIC 16F886 with 9 button program with CCS


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    1

    Default [Help] PIC 16F886 with 9 button program with CCS

    Anyone can help pls


    Hi all. I'm a newbie in PIC and i do this project


    Input :


    Port A0-A5
    Port C0-C2


    Output :


    PortB


    When i push a button form 1-9 Pic will output random on PortB. This is program i have written. I have simulation on Proteus, it working but sometime when i push button, output is blinking, not constant. Is there wrong in this program?


    And when I download program to real chip PIC 16F886, it not working. Pls help me make good and clear program. Many thanks !


    Hi all. I'm a newbie in PIC and i do this project


    Input :


    Port A0-A5
    Port C0-C2


    Output :


    PortB


    When i push a button form 1-9 Pic will output random on PortB. This is program i have written. I have simulation on Proteus, it working but sometime when i push button, output is blinking, not constant. Is there wrong in this program?


    And when I download program to real chip PIC 16F886, it not working. Pls help me make good and clear program. Many thanks !


    #include <16F886.h>


    #use delay(crystal=20000000)


    #define sw1 PIN_A0
    #define sw2 PIN_A1
    #define sw3 PIN_A2
    #define sw4 PIN_A3
    #define sw5 PIN_A4
    #define sw6 PIN_A5


    #define sw7 PIN_C0
    #define sw8 PIN_C1
    #define sw9 PIN_C2


    #FUSES NOWDT //No Watch Dog Timer
    #FUSES NOBROWNOUT //No brownout reset
    #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O


    void main()
    {


    while(TRUE)
    {
    //sw1
    if(!input(sw1))
    OUTPUT_B(0x70);


    ///sw2
    else if(!input(sw2))
    OUTPUT_B(0x0C);


    ///sw3
    else if(!input(sw3))
    OUTPUT_B(0x04);


    ///sw4
    else if (!input(sw4))
    OUTPUT_B(0x07);


    ///sw5
    else if (!input(sw5))
    OUTPUT_B(0x02);


    ///sw6
    else if (!input(sw6))
    OUTPUT_B(0x05);




    ///sw7
    else if (!input(sw7))
    OUTPUT_B(0x0E);


    ///sw8
    else if (!input(sw8))
    OUTPUT_B(0x0B);


    ///sw9
    else if (!input(sw9))
    OUTPUT_B(0x0A);


    else
    OUTPUT_B(0x00);
    }


    }







  2. #2


    Did you find this post helpful? Yes | No

    Default Re: [Help] PIC 16F886 with 9 button program with CCS

    You would be better off looking for a C forum which I think is your programming language - this is for Melabs Picbasic language.

Similar Threads

  1. Toggle program branch ussing interrupot by button?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 14th September 2013, 09:58
  2. Problem proramming PIC 16F886 with PICKIT2?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 11th January 2012, 23:23
  3. Problem with porta for 16F886(PIC 28X1)
    By Anghel Cosmin in forum Off Topic
    Replies: 2
    Last Post: - 26th February 2009, 13:07
  4. PIC never reacts to Button
    By AlfonsoB in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th November 2008, 16:44
  5. PIC Basic Pro Ver 2.47 Can't Do 16F886
    By NO2K in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th April 2008, 19:02

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts