davoud
Full Member level 2
Hello Everyone,
I am inexperienced in micro-controllers. I want read data from a "six-pin DIP switch" attached to the port A of PIC 16F876A and show data on two 7-segment display connected to port B and port C. I have a problem to read data.
Thanks.
My program :
I am inexperienced in micro-controllers. I want read data from a "six-pin DIP switch" attached to the port A of PIC 16F876A and show data on two 7-segment display connected to port B and port C. I have a problem to read data.
Thanks.
My program :
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include "Display_utils.h" unsigned int digit_no, digit10, digit1, digit ; void main() { PORTC = 0; // clear PORTA (make sure both displays are off) TRISC = 0; // designate PORTA pins as output PORTB = 0; // clear PORTD (make sure LEDs are off) TRISB = 0; // designate PORTD pins as output TRISA = 1; // designate PORTA pins as input do { digit = PORTA ; digit1 = digit % 10; digit10 = (digit / 10) % 10 ; PORTC = mask(digit1); // prepare ones digit PORTB = mask(digit10); // prepare tens digit } while (1); // endless loop }
Last edited by a moderator: