Hi all, I appreciate you taking time to view this thread, im not sure if its in the wrong place etc, but its my first post. I'm doing a dice project, using a pic16f877 microcontroller I need to produce two seven segment displays which would emulate the outcomes of two random dice, ive got to a certain stage but I need help, im using c language by the way, anything would be appreciated, thank you.
here's my code:
Code:
#include <pic.h>
const static unsigned char segment_code[] = { 0x3F, //0
0x06, //1
0x5B, //2
0x4F, //3
0x66, //4
0x6D, //5
0x7C };
int counter1 = 0, counter2 = 0;
bit button_up = 0;
void main(void)
{
TRISD = 0X00;
TRISC = 0X00;
TRISB = 0xFF;
counter1 = rand() % 6 + 1;
counter2 = rand() % 6 + 1;
for (;;)
{
if (RB0 == 1)
button_up = 1;
else
{
if (button_up == 1)
{
button_up == 0;
}
}
PORTC = segment_code[counter1];
PORTD = segment_code[counter2];
}
}