Registered Users          New User?
Picture of Sam Christy
Re: memory game
by Sam Christy - Tuesday, December 8, 2009, 10:11 AM
  Cody,

The major problem with the code you posted is that it does not have a main function. All C files must include a main function. This is the initial function that the compiler looks for before processing the rest of the file.

Another suggestion is that you format your code. Below is a an example of the code you posted above formated with indents. There are a number of ways to format your code but without any indents it is very difficult to read and debug. Notice that reading the formatted code below there is clearly an curly brace missing that the bottom of the file.

Sam


#include "mxapi.h"

#define Y_BUTTON RB4
#define R_BUTTON RB5
#define O_BUTTON RB6
#define G_BUTTON RB7

void light(char color)
{
TRISB4 = 1;
TRISB5 = 1;
TRISB6 = 1;
TRISB7 = 1;

while(1==1)
{
if(Y_BUTTON==0)
{
light(0);
}
else if(R_BUTTON==0)
{
light(1);
}
else if(O_BUTTON==0)
{
light(2);
}
else if(G_BUTTON==0)
{
light(3);
}
delay_ms(100);
}