|
|
View previous topic :: View next topic |
Author |
Message |
alperem
Joined: 22 Feb 2017 Posts: 2
|
Pic countdown timer |
Posted: Wed Feb 22, 2017 4:11 pm |
|
|
Hi guys i am currently trying to build a timer for my uv exposure box but i got stuck. Can you guys look at my code and tell me what i need to do ? With this code i am able to use 3 seven-segment displays and count to three digits.
But what i want is to count them backward not forward and also can you please tell me how can i implement time selection. For example i want to choose 5 mins then push start button and counting starts. I am open to all suggestions. Thank you all...
Code: |
#include <16f877.h>
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=4000000)
int i,k,c;
const int digit[16]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7C, 0x07, 0x7F, 0x6F, 0x77};
void main ()
{
while(1)
{
for(i=0;i<=9;i++)
{
for(k=0;k<=9;k++)
{
for(c=0;c<=9;c++)
{
output_b(digit[i]);
output_d(digit[k]);
output_c(digit[c]);
delay_ms(500);
}
}
}
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 23, 2017 4:10 am |
|
|
Quote: | But what i want is to count them backward |
You could change your loop so it's like this:
Code: | signed int8 i, k, c;
for(i=9; i>=0 ;i--)
{
} |
And change the other loops the same way.
Then it counts down like this:
Quote: | 9 8 7 6 5 4 3 2 1 0 |
|
|
|
alperem
Joined: 22 Feb 2017 Posts: 2
|
|
Posted: Thu Feb 23, 2017 5:28 am |
|
|
Okay now it counts down backward thanks, but now how can i implement set, reset, start button to it and timer? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Thu Feb 23, 2017 5:47 am |
|
|
This is all basic learning to program.
This forum is not a 'teach you' forum.
However you should start by looking at things like keyboard scanning code (code forum, and the examples). Then look at timer code (same places).
Put them together, and you have a start.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Feb 23, 2017 6:13 am |
|
|
Also.. look at the 'stopwatch' example program in the 'examples' folder that CCS supplies....
actually you should spend a day or two and look at the examples as thr's a ton of great info on how to program( code CCS C ) PICs. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Feb 23, 2017 9:41 am |
|
|
alperem wrote: | Okay now it counts down backward thanks, but now how can i implement set, reset, start button to it and timer? |
Like you've already been told this is a help forum.
However, your job breaks down into several modules.
I have an exposure unit (bought in) which has three buttons.
An up button, down button and a start button.
The tasks are Set Time with up and down buttons, then Start time down.
If you want to reset to zero you could either use a fourth button or simply remove and restore power.
You could press start again to abort a time down.
You have several decisions to make.
My unit simply counts in seconds, but you could do minutes and seconds.
At the end of the time down it stays at zero, you could automatically set to the set time you last used. (Probably more useful.)
It's your project, you make the decisions, you learn 'C', we will try to help.
Mike |
|
|
|
|
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
|