Can someone help me with my 7 segment display dice programming ?
watarui
Posts: 1
I am new to c programming and layout of circuit board.I hope there is some kind soul out there to help me with it.
I have completed my codes for it but the building fails when i build all in MPLAB program.
#include<p18f4520.h>
#include <delays.h>
#include <stdio.h>
#include <stdlib.h>
#define Digit1 PORTC
#define Digit2 PORTC
unsigned char Pattern (unsigned char i)
{
unsigned char Pattern;
unsigned char SEGMENT[6]={0x6,0x5B,0x4F,0x66,0x6D,0x7D};
Pattern=SEGMENT;
return(SEGMENT);
}
void main()
{unsigned char char Msd,Lsd,Cnt=6
ADCON1=0x0F;
TRISC=0; //output
TRISB=0;//output=RB0,RB1
Digit1=0//disable 1
Digit2=0;//disable 2
}
For(;; )
{
int Num;
char lastNum,Digit1,Digit2;
Num=rand();
lastNum=(char)Num;
if(Digit1==1)
{
Msd=Cnt/6
Digit1=(0x0F & lastNum);
PORTC; DISPLAY(Msd);
Delay10KTCYx (50)
else
{
Lsd=Cnt;
Digit1=0;
Digit2=(0xF0 & lastNum );
Digit2: Digit2>>4;
PORTC: Display(Lsd)
Delay10KTCYx (50)
}
}
Here is the layout of the 7 segment display:
https://lms.tp.edu.sg/bbcswebdav/pid-1257209-dt-content-rid-1741819_2/courses/1314OCT-05-EMC2001/1213OCT-05-EMC2001_ImportedContent_20121012015833/targetboard.pdf
I have completed my codes for it but the building fails when i build all in MPLAB program.
#include<p18f4520.h>
#include <delays.h>
#include <stdio.h>
#include <stdlib.h>
#define Digit1 PORTC
#define Digit2 PORTC
unsigned char Pattern (unsigned char i)
{
unsigned char Pattern;
unsigned char SEGMENT[6]={0x6,0x5B,0x4F,0x66,0x6D,0x7D};
Pattern=SEGMENT;
return(SEGMENT);
}
void main()
{unsigned char char Msd,Lsd,Cnt=6
ADCON1=0x0F;
TRISC=0; //output
TRISB=0;//output=RB0,RB1
Digit1=0//disable 1
Digit2=0;//disable 2
}
For(;; )
{
int Num;
char lastNum,Digit1,Digit2;
Num=rand();
lastNum=(char)Num;
if(Digit1==1)
{
Msd=Cnt/6
Digit1=(0x0F & lastNum);
PORTC; DISPLAY(Msd);
Delay10KTCYx (50)
else
{
Lsd=Cnt;
Digit1=0;
Digit2=(0xF0 & lastNum );
Digit2: Digit2>>4;
PORTC: Display(Lsd)
Delay10KTCYx (50)
}
}
Here is the layout of the 7 segment display:
https://lms.tp.edu.sg/bbcswebdav/pid-1257209-dt-content-rid-1741819_2/courses/1314OCT-05-EMC2001/1213OCT-05-EMC2001_ImportedContent_20121012015833/targetboard.pdf
Comments
Why don't you tell us a bit more about your setup?
A quick glance at the code shows me you have not.
Your main() function dos not reach or call any of the rest of the code.
Anyway, if it does not compile then posting the first compiler error message would help us help you.
Of course if you read that message you will probably see the problem yourself.
Take a step by step approach, Remove everything but the #includes and the main function. Try to compile that. When it does start to add your code back in piece by piece and be sure it compiles at each step.
Generally it's wise to say when you need help with a homework problem else it looks like you are getting us to do your home work for you.