I'm learning PIC (pic18f4550) and pretty new to microcontroller programming. I'm trying get value of three button on PORTA and send it to a 8x8 led matrix as X coordinates through a 74LS595. The problem is that the value go to the led matrix doesnt change when i pressed the buttons to create different value. I'm simulating on Proteus so I guess I don't need debounce function. Here's my code and schematic:
#include<p18f4550.h> #define SCK LATBbits.LATB0 #define DATA PORTBbits.RB1 #define SCL PORTBbits.RB2 void Data_in(unsigned char k){ DATA=k; SCK=0; SCK=1; } void LatchData(){ SCL=0; SCL=1; } void Send1byte(unsigned char data) { unsigned char i,temp; for(i=0;i<8;i++) { temp = data & (1<<i); if(temp) { DATA = 1; } else { DATA = 0; } SCK = 0; SCK = 1; } SCL = 0; SCL = 1; } unsigned char getMatrixX(unsigned char in_X) { switch(in_X) { case 0: // the value stuck here return 0b01111111; case 1: return 0b10111111; case 2: return 0b11011111; case 3: return 0b11101111; case 4: return 0b11110111; case 5: return 0b11111011; case 6: return 0b11111101; case 7: return 0b11111110; default: return 0b11111111; } } void main() { TRISA = 1; TRISC = 1; TRISB = 0; TRISD = 0; PORTD = 0x80; while(1){ Send1byte(getMatrixX(LATA)); } } This is link to my schematic: my Schematic
Really appreciate any solutions and advices. Sorry for my bad english.
