I am having problems with my code it is not displaying as I want it to, I have to have it finished in 2 days.
Rich (BB code):
/* 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: