PIC MCU: Using pointers to alter output

cmicrocontrollerpic

so I've been trying to create a circuit with a PIC16F917, a button, and three LED's, where upon a button press the LED output changes, like the button press cycles through different modes. I've been trying to do this utilising pointers, in a way like a multiplexer, where the value of an integer depicts the certain output mode (interpreted by outputconfig()), and the push of a button increments that integer by 1; but don't really know what's going wrong.

Also, why does XC8 say upon the build, that the use of "delay()" and "outputconfig()" within main() is a "function declared an implicit int"? And why does it still work?

Any help and/or guidance would be much appreciated. Below is the code I am working with. Thankyou!

#include <xc.h>
#include <pic16f917.h>
#include "configbits.h"
#include "definitions.h"

int value;
int *output;
int result;

int main()
{
    TRISEbits.TRISE0=1;

    TRISDbits.TRISD5=0;
    TRISDbits.TRISD6=0;
    TRISDbits.TRISD7=0;

    while(1)
    {
        if(1==IN1)
        {
            delay();
            if(1==IN1)
            {
                output=&value+1;
                result=*output;
                outputconfig();
            }
        }
    }
}

int delay()
{
    int i;
    for(i=0;i<1000;i++){}
}

int outputconfig()
{
    if(0==value)
    {
        OUT1=1;
        OUT2=0;
        OUT3=0;
    }
    if(1==value)
    {
        OUT1=0;
        OUT2=1;
        OUT3=0;
    }
    if(2==value)
    {
        OUT1=0;
        OUT2=0;
        OUT3=1;
    }
    else
    {
        NOP();
    }
}

Best Answer

You aren't initialising value or result - in fact although you are assigning a value to result with: *result=output; you never use result again so this line is completely redundant. this line: output=&value+1; says take the address of value, add 1 to it (the location of the place after value ???) and then make output points to it

I think what you meant to do was:

output = &value;    // do this once before the loop to make output point at value
   // or you could initialise it when you declare it like this:
int *output = &value ;

*output = *output+1 // in the loop. increase 'value'

comments by others are correct regarding function declarations