mojocyber
Newbie level 2
- Joined
- Jan 3, 2014
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 23
I am having problems with my code, it compiles but does not display the digits how I want. can someone help, very new to programming.
:???:
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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 /* Created: Mon Nov 25 2013 * Processor: PIC16F877 * Compiler: HI-TECH C for PIC10/12/16 */ /* double 7 Segment interfacing programme*/ #include <pic.h> #include <stdlib.h> #include <time.h> const static unsigned char segment_code[] = { 0x3F, //0 0x06, //1 0x5B, //2 0x4F, //3 0x66, //4 0x6D, //5 0x7C, //6 0x07, //7 0x7F, //8 0x67}; //9 char counter1 = 0; char counter2 = 0; bit button_up = 0; void main(void) { TRISC=0x00; // all outputs TRISD=0x00; // all outputs TRISB=0xFF; // all inputs srand(rand()); // seeds random with time for(;;) // start of superloop { if(RB0==1) button_up=1; else { if (button_up==1) { button_up=0; counter1=rand()%6+1; counter2=rand()%6+1; } } PORTC=segment_code[counter1]; PORTD=segment_code[counter2]; } };
Last edited by a moderator: