Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming help

Status
Not open for further replies.
hi everybody i want display 0-100 in my development kit.here is my program that wil display fomm 0-9.so please give me some suggection for making the changes.




#include<pic.h>
#include<stdio.h>


void main()

{
int i;
char map[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
TRISD=0x00; // for diplay/led output
TRISC=0x00; // latch control
TRISB=0X00; // display control
RC1=0;
RC0=0;
i=0;

while(i<9)
{

i++;
PORTD=map; //masking the values
PORTB=0x01; //display enable for first display
_delay(196999); //delay
PORTB=0x00; //turn off the display
_delay(196999); //delay

if(i==9) //just chk whethr i=9?
{
RC1=1; //led enable

}
else //buzzer enable
{
RB5=1;
}
}
 
You will get more help if you post which development kit you are using. A link would be even better than just the name.
 
Last edited:
Your LED display is multiplexed.
That means, you'll need to output the 1000's single digit code from map[] on PORTD and then turn on digit one (RB0=1). Then delay apx 2ms. Then turn off digit one (RB0=0)
Then you'll need to output the 100's single digit code from map[] on PORTD and then turn on digit two (RB1=1). Then delay apx 2ms. Then turn off digit two (RB1=0)
Then you'll need to output the 10's single digit code from map[] on PORTD and then turn on digit three (RB2=1). Then delay apx 2ms. Then turn off digit three (RB2=0)
Then you'll need to output the 1's single digit code from map[] on PORTD and then turn on digit four (RB3=1). Then delay apx 2ms. Then turn off digit four (RB3=0)
Then you repeat the above for as long as you want to display the number. This is best done in an interrupt routine, but it is not mandatory.
The above will display a static number on the display.
 
Last edited:
Your LED display is multiplexed.
That means, you'll need to output the 1000's single digit code from map[] on PORTD and then turn on digit one (RB0=1). Then delay apx 2ms. Then turn off digit one (RB0=0)
Then you'll need to output the 100's single digit code from map[] on PORTD and then turn on digit two (RB1=1). Then delay apx 2ms. Then turn off digit two (RB1=0)
Then you'll need to output the 10's single digit code from map[] on PORTD and then turn on digit three (RB2=1). Then delay apx 2ms. Then turn off digit three (RB2=0)
Then you'll need to output the 1's single digit code from map[] on PORTD and then turn on digit four (RB3=1). Then delay apx 2ms. Then turn off digit four (RB3=0)
Then you repeat the above for as long as you want to display the number. This is best done in an interrupt routine, but it is not mandatory.
The above will display a static number on the display.










#include<pic.h>
#include<stdio.h>


void main()

{
int i;
int c;
char map[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

TRISD=0x00; // for diplay/led output
TRISC=0x00; // latch control
TRISB=0X00; // display control
RC1=0;
RC0=0;
i=0;
c=0;
while(1)
{

PORTD=map; //masking the values
RB3=1; //display enable for first display
_delay(7000); //delay
RB3=0;

PORTD=map; //masking the values
RB2=1; //display enable for first display
_delay(7000); //delay
RB2=0; //turn off the display
PORTD=map;
//masking the values
RB1=1; //display enable for first display
_delay(7000); //delay
RB1=0;

PORTD=map; //masking the values
RB0=1; //display enable for first display
_delay(7000); //delay
RB0=0;
}
}

now am getting proper multiplexed didplay.then how i can link this one with rest of program?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top