The Philippine Electronics and Technology Forum
February 09, 2012, 01:05:43 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: HELP: clock program  (Read 401 times)
balingkit08
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Gender: Female
Posts: 4


I am striving to learn


« on: August 30, 2008, 11:36:28 PM »

-I need a clock program that displays time using dual 7 segment through PIC16F84A...
Can someone help me?
Logged

-ahem
The Philippine Electronics and Technology Forum
« on: August 30, 2008, 11:36:28 PM »

 Logged
dimps
LR44 Battery
*

Pogi/Ganda Points: 0
Offline Offline

Posts: 0


« Reply #1 on: September 02, 2010, 11:16:05 AM »

#if defined(__PCM__)
#include <16F877.h>
#include <stdio.h>
#include <stdlib.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void findnumbers(int temp);
void sendhex(int number, int digit);
void displaynumbers(int tens, int ones);
int getavgtemp();




void main() {
  int temp;
   int i=0;
  set_tris_b(0);

  temp = 0;
  output_b (0x00);
  while(TRUE) {
    if(kbhit()) {
        temp=getc();
        delay_ms(500);
            findnumbers(temp);
    }
  }
}




// function to find number
void findnumbers(int temp)
   {

   int tens = 0; // tens position
   int ones = 0; // ones position

   output_high(PIN_D0);
   if (temp < 100) // temp should never be over 100
   {
    tens = (temp/10)%(10);
    ones = (temp%10);
   }else{tens, ones = 2;}
   displaynumbers(tens,ones);
}

// this converts a number to the desired high/low combination
// for the 7 seg led display
void sendhex(int number, int digit)
   {
   output_high(PIN_D1);
   output_e (0x00);
   // send hex to port b to make number

   if (number == 0){output_b (0xC0);} // output 0 to port b
   if (number == 1){output_b (0xF9);} // 1
   if (number == 2){output_b (0xA4);}
   if (number == 3){output_b (0xB0);}
   if (number == 4){output_b (0x99);}
   if (number == 5){output_b (0x92);}
   if (number == 6){output_b (0x82);}
   if (number == 7){output_b (0xF8);}
   if (number == Cool{output_b (0x80);}
   if (number == 9){output_b (0x90);}


   //turn on the digit(send high to common cathode via transistor)
   if (digit == 1){output_high(PIN_E0);}
   if (digit == 2){output_high(PIN_E1);}
   output_low(PIN_D1);

   }

void displaynumbers(int tens, int ones)// send to led
   {
   int i = 0;
   output_high(PIN_D2);


   if(tens > 0)
   {
   sendhex(tens, 2);
   sendhex(ones, 1);
   }else{
   sendhex(ones, 2);
   }
   output_low(PIN_D2);
   }

try this from overmind
Logged
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Simple accurate clock pulse source from an ordinary quartz clock
General Digital Design
spidamang 11 1696 Last post January 04, 2012, 06:28:10 PM
by dummy_c
Program for shot clock and score for zilog score board
Zilog Microcontrollers
sphinxnator_15 5 1583 Last post April 14, 2008, 12:35:17 PM
by janbobis
GPS Synchronize Clock
General Wireless Communication
piona 8 1207 Last post April 02, 2008, 12:47:49 PM
by piona
Z86 based clock
Microcontroller/Microprocessor Unit Projects and Programming
Decoder 3 639 Last post September 20, 2009, 11:52:27 PM
by marcelino
digital clock program in turbo C..pls help :( « 1 2 »
Computer Software
eLi_chan 25 2013 Last post March 22, 2010, 11:13:55 PM
by zeitcheist
shot clock program using c++ tulong!!!
COE Students
neon11 1 535 Last post March 08, 2010, 11:13:36 AM
by mini_mouse ^_^
pa2long naman po gumawa ng program naung clock
PIC Microcontrollers
sonic05 18 445 Last post October 03, 2010, 11:05:38 AM
by sonic05
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!