dual 7-segment dice

Thread Starter

mojocyber

Joined Dec 4, 2013
3
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];
    }
};
:confused:
 
Last edited by a moderator:

tshuck

Joined Oct 18, 2012
3,534
So, what is it displaying? Does anything show up? Where is your schematic? Have you checked the wiring? What is the target functionality? Have you isolated the programmer after programming tree target so as to not interfere with the display functionality (port C)?

For wanting help, you haven't provided much information, aside from a code dump...
 
Last edited:

WBahn

Joined Mar 31, 2012
29,976
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.
So... are we supposed to use our highly advanced mind-reading skills to know how you want it to display?

You need to CLEARLY describe what you WANT it to do and what it IS doing.
 

Thread Starter

mojocyber

Joined Dec 4, 2013
3
You are required to design an electronic dice simulator. The design will incorporate two seven segment displays, a pushbutton and the PIC16F877. A suitable circuit design developed in Proteus will be required to simulate the circuit and the software developed.
When the push button is pressed both displays will show rapidly changing numbers between 1 and 6. When the button is released the two random numbers generated will be displayed.
Requirements
You will need to develop the circuit in the ISIS part of Proteus 8 and the C code for the PIC16F877, using the HiTech 'C' compiler. The report should document the design procedure with sufficient detail so that it could be redeveloped by others.

I have 1 7-segment connected to RCO to RC6
and 1 7-segment connected to RDO to RD6
push button connected to RBO

it is not outputting full digits
 

shteii01

Joined Feb 19, 2010
4,644
I am going to start with a couple of things that I find odd.

1.
The dice have values between 1 and 6. Your segment_code array contains 0, 7, 8, 9. You are asked to display 1, 2, 3, 4, 5, 6. Why do you have 0, 7, 8, 9?

2.
Ok. I got this part wrong.
 

tshuck

Joined Oct 18, 2012
3,534
it is not outputting full digits
Is that on both, or just one display? If just one, which?
Does it display incomplete characters, or characters that don't make sense?

Have you tried just making both segments count up to 7 to verify the connections?

Since you have a schematic, how about you post it?
 

absf

Joined Dec 29, 2010
1,968
Are you sure you're getting any display on the CC 7-SEG LED?

I see that you're using 220K resistors for current limiters for your display. The rest of the circuit are OK. I'd put a 10K resistor for the MCLR to Vcc.

Allen
 

djsfantasi

Joined Apr 11, 2010
9,156
Can someone else count the connections to the 7 segment display on the left? I don't see enough resistors. My eyes are not so good.
 

tshuck

Joined Oct 18, 2012
3,534
Pin 36 should be grounded, as this is configured to be PGM for low voltage programming.

As others have noted, add a resistor to RC2 and reduce the resistor values... try 330Ω.
 
Top