kaizer002 said:Hi to all,
I'm making a project and I choose multiplexing 4 seven segment displays with my PIC16F877a.
Here's how it goes: the first two seven segments will display the "Minutes" and the last two seven segments will display "Seconds".
Please help me with the source code since I'm having difficulty with that. Thanks in advance..!
/*
* Project name:
Display7Seg_02 (Usage of 2 7Seg. displays)
* Copyright:
(c) MikroElektronika, 2005-2008.
* Description:
This code demonstrates displaying numbers (0,1,2..99) on two 7-segment
displays. Each digit is on for 1 second.
* Test configuration:
MCU: PIC16F877A
Dev.Board: EasyPIC5
Oscillator: HS, 08.0000 MHz
Ext. Modules: -
SW: mikroC v8.0
*/
#include "Display_utils.h"
unsigned short digit_no, digit10, digit1, digit, i;
void interrupt() {
if (digit_no==0) {
PORTA = 0; // Turn off all 7seg displays
PORTD = digit1; // send mask for ones digit to PORTD
PORTA = 1; // turn on 1st 7 seg., turn off 2nd
digit_no = 1;
} else {
PORTA = 0; // Turn off all 7seg displays
PORTD = digit10; // send mask for tens digit to PORTD
PORTA = 2; // turn on 2nd 7 seg., turn off 1st
digit_no = 0;
}
TMR0 = 0; // clear TMRO
INTCON = 0x20; // clear TMR0IF and set TMR0IE
}
void main() {
OPTION_REG = 0x80; // Timer0 settings
TMR0 = 0;
INTCON = 0xA0; // Disable PEIE,INTE,RBIE,T0IE
PORTA = 0; // clear PORTA (make sure both displays are off)
TRISA = 0; // designate PORTA pins as output
PORTD = 0; // clear PORTD (make sure LEDs are off)
TRISD = 0; // designate PORTD pins as output
do {
for (i = 0; i<=99; i++) { // count from 0 to 99
digit = i % 10u;
digit1 = mask(digit); // prepare ones digit
digit = (char)(i / 10u) % 10u;
digit10 = mask(digit); // prepare tens digit
Delay_ms(1000);
}
} while (1); // endless loop
}
#include<16f877.h>
#fuses XT,NOLVP,NOWDT,PUT
#use delay (clock=1000000) // defind crystal = 4MHz
#byte port_d=8
#byte port_a=5
byte CONST LED_MAP[10]={0x3F,0x06,0x5b,0x4F,0x66,0x6D,0x7D,0x07,0X7F,0x6F};
//===========================================
// this function use to display number 00=99
// input : n = number to display
//===========================================
void display_number(int n)
{
output_d(LED_MAP[n/10]);//tens position;n=0 to 9
output_low(PIN_A2);
delay_ms(20);
output_high(PIN_A2);
output_d(LED_MAP[n%10]) ;//unit position
output_low(PIN_A1);
delay_ms(20);
output_high(PIN_A1);
}
//============================================
// main program
//============================================
void main()
{
int i,count=0;
while(TRUE)
{
for (i=0;i<=200;i++)
display_number(count); // dispay 200 times
count=(count==59) ? 0: count+1;//count+1=++count
}
}
while(TRUE)
{
for (i=0;i<=200;i++)
display_number(count); // dispay 200 times
count=(count==59) ? 0: count+1;//count+1=++count
}
HI mr DAHROUG
LM35 output is connectd to PIC any PORT A pin.. u can convert Analog Temp value into digital ...
and how u connected these 3 seven segment display DIGITS..??
R u using Single port to 3 DIGIT if its true u should switch COM1, COM2, COM3 using other port pin so that u can Switch ON each sement in minute time....
if ur using Individual port for every digit.. its so simple.. to write the code...
k reply me so that i can get u .........
Added after 3 minutes:
unsigned char n,d,count=0;
unsigned char a,b,c;
void keypadscan();
void display();
void disp_dig(char );
void main()
{
d=123;
while(1)
{
n=d;
display();
//keypadscan();
}
}
void display() // DISPLAYING all DIGITS
{
TRISB=0; // Configured PORTB as OUTPUT
TRISD=0; // Configured PORTD as OUTPUT
if(count==0)
{
a=n%10; n=n/10; // a=3
b=n%10; n=n/10; // b=2
c=n%10; n=n/10; // c=1
count=1;
}
disp_dig(c);
PORTD=0x01; // SD1 ON
DelayUs(500);
disp_dig(b);
PORTD=0x02; //SD2 ON
DelayUs(500);
disp_dig(a);
PORTD=0x04; //SD3 ON
DelayUs(500);
}
void disp_dig(char k)
{
switch(k)
{
case 0:{ PORTB=0X3F; break; }
case 1:{ PORTB=0X06; break; }
case 2:{ PORTB=0X5B; break; }
case 3:{ PORTB=0X4F; break; }
case 4:{ PORTB=0X66; break; }
case 5:{ PORTB=0X6D; break; }
case 6:{ PORTB=0X7D; break; }
case 7:{ PORTB=0X07; break; }
case 8:{ PORTB=0X7F; break; }
case 9:{ PORTB=0X6F; break; }
}
}
i thnk u get from this code..............how to use 3 digit display
Added after 1 minutes:
Here SD1 , SD2 , SD3 are.. COM pins of 3 DIGITS
Added after 1 minutes:
in this code SD1, SD2 SD3 are the
COM1, COM2 , COM 3 of 3 DIGITs Supply pins through ULN
so understand the logic i hope u can do it.. by seeing this
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?