|
|
View previous topic :: View next topic |
Author |
Message |
jackhammer
Joined: 05 Sep 2011 Posts: 8
|
do can change code as clock ? |
Posted: Sat Sep 24, 2011 9:33 am |
|
|
this code normal will count 1- 9999 but me wanna change as clock
Code: | #include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
unsigned char DisBuff[5];
unsigned char Scan_Column[]={0xfe,0xfd,0xfb,0xf7,0xff};
unsigned char SegMent_Code[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void Decimal_To_7_SegMent(unsigned int16 Num);
void Scan_Display(void);
void main(void)
{
unsigned int16 Number=0000;
set_tris_b(0x00);
set_tris_d(0x00);
while(true)
{
Decimal_To_7_SegMent(Number);
Scan_Display();
Number++;
}
}
void Decimal_To_7_SegMent(unsigned int16 Num)
{
unsigned int16 temp;
DisBuff[0]=SegMent_Code[Num/1000];
temp=Num%1000;
DisBuff[1]=SegMent_Code[temp/100];
temp=Num%100;
DisBuff[2]=SegMent_Code[temp/10];
temp=Num%10;
DisBuff[3]=SegMent_Code[temp];
}
void Scan_Display(void)
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<4;j++)
{
output_b(DisBuff[j]);
output_d(Scan_Column[j]);
delay_us(1000);
output_b(DisBuff[4]);
output_d(Scan_Column[4]);
delay_us(1000);
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sat Sep 24, 2011 10:32 am |
|
|
What type of 'clock' ?
That doesn't tell anyone what you want to do.
You could 'clock' pulses,'real time',speed of passing cars,etc.
You'll need to define the parameters of your 'clock'.
The better the description of what you want, the better the responses you'll get from this forum.
Also be aware that Proteus/ISIS is FULL of bugs, errors, and invalid DRCs so if and that's a BIG if, code 'works' in simulation there is a HUGE chance it'll never work in the real world.I strongly suggest you get real parts and get some true hands on experience. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|