Code:
#include <stdio.h> unsigned char pattern (int); // set up function // int main(void){ /******************* Declare the port addresses **********************/ unsigned char *DDRA = (unsigned char *)0x0002; unsigned char *PORTB = (unsigned char *)0x0001; unsigned char *DDRB = (unsigned char *)0x0003; unsigned char *PTH = (unsigned char *)0x0260; unsigned char *DDRH = (unsigned char *)0x0262; unsigned char *PERH = (unsigned char *)0x0264; /******************* Declare variables *******************************/ unsigned char threshold; unsigned char index; unsigned char i; /******************* Declare function prototypes**********************/ void wait(int); //set up of function // /************************** Scanner Data ******************************/ unsigned char scanner[ 255 ] = { 50, 4, 9, 14, 18, 23, 26, 29, 30, 31, 32, 34, 37, 41, 47, 54, 63, 71, 80, 87, 92, 94, 94, 92, 89, 85, 83, 83, 86, 93,102, 115,128,141,153,161,164,164,160,152,144, 137,132,132,136,146,161,178,196,213,226 }; /******************* Set up I/O ports ********************************/ *DDRH = 0x00; /* make Port H an input port */ *PERH = 0xFF; /* enable Port H */ *DDRA = 0xFF; /* make Port A an output port */ *DDRB = 0xFF; /* make Port B an output port */ /******************* Main loop ***************************************/ *PORTB = 255; // This clears the display on PORTB // threshold = *PTH; // Make threshold equal to *PTH // index = 1; for ( i = 1; i <= scanner[0] && scanner [i] < threshold; i++) { *PORTB = pattern (scanner[i]/32); wait (1); } if ((index < threshold)) { printf("threshold reached at reading %d with a current value %d." ,index ,scanner[index] ); } else { printf (" Threshold not reached after %d readings." ,scanner[0]); } return 0 ; } /******************* Pattern Function **********************************/ unsigned char pattern (char sw_data) { unsigned char LedTable [8] = { 0b00000001, 0b00000011, 0b00000111, 0b00001111, 0b00011111, 0b00111111, 0b01111111, 0b11111111 }; unsigned char data; unsigned char display; unsigned char sw_on; unsigned char sw_off; data = sw_data; sw_on = ((unsigned char) LedTable[data]); sw_off = sw_data & 0b11111111; if ( sw_off & 0b00010000) { display = sw_on | 0b10000000 ; } else { display = sw_on & 0b01111111; } } /********************** Wait Function **********************************/ void wait (int seconds) { unsigned int i; unsigned int j; unsigned int k; for ( k = 0; k <= seconds; k++) { for ( i = 0; i <= 50; i++) { for (j =0; j <= 2000; j++); } } }
the error I am receiving is that there is conflicting types for pattern, it directs me to the two pattern uses, this is the only error in the program.