Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <xc.h>
- #include "config.h"
- static const unsigned char nums[] = {
- 0b00111111,
- 0b00110000,
- 0b01101101,
- 0b01111001,
- 0b01110010,
- 0b01011011,
- 0b01011111,
- 0b00110001,
- 0b01111111,
- 0b01110011,
- 0b00000000,
- };
- void main()
- {
- ADCON1 |= 0x0F; // Configure all ports with analog function as digital
- CMCON |= 7; // Disable comparators
- TRISA=0xFF;
- TRISB=0;
- int old = PORTA;
- int i = 0;
- for(;;){
- int n = PORTA;
- if ((n == 1) && !(old == 1)) {
- i++;
- if (i > 10) i = 0;
- PORTB=nums[i];
- }
- old = n;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement