0% found this document useful (0 votes)
38 views

Interface 7 Segment With MC. Display The Number From 0-9 On 7 Segment

The document contains code to control a 7 segment display and stepper motor. The 7 segment code uses an array to display numbers 0-9 by turning on the appropriate LEDs. The stepper motor code defines the motor coils as outputs and uses buttons to control the direction by energizing different coil combinations.

Uploaded by

Waqas Mehmood
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Interface 7 Segment With MC. Display The Number From 0-9 On 7 Segment

The document contains code to control a 7 segment display and stepper motor. The 7 segment code uses an array to display numbers 0-9 by turning on the appropriate LEDs. The stepper motor code defines the motor coils as outputs and uses buttons to control the direction by energizing different coil combinations.

Uploaded by

Waqas Mehmood
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Interface 7 Segment with MC.

Display the number from 0-9


on 7 Segment
HARDWARE

CODING
#define LED PORTC
int j=0;
int i=0;
void main()
{
unsigned char
LD[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
TRISC=0;
LED=0;
while(1)
{
for(i=0;i<10;i++)
{
LED=LD[i];
delay_ms(200);
}
}
}

Controlling direction of Stepper Motor


HARDWARE

CODING

#define S1 PORTC.F2
#define S2 PORTC.F3
#define S3 PORTC.F4
#define S4 PORTC.F5
void main(void)
{
TRISC.F2=0;
TRISC.F3=0;
TRISC.F4=0;
TRISC.F5=0;
TRISC.F0=1;
TRISC.F1=1;
S1=0;
S2=0;
S3=0;

S4=0;
while(1)
{
if(PORTC.F0==1 && PORTC.F1==0)
{
S1=1;
S4=1;
S2=0;
S3=0;

}
if(PORTC.F0==0 && PORTC.F1==1)
{
S2=1;
S3=1;
S1=0;
S4=0;

}
if((PORTC.F0==0 && PORTC.F1==0) || (PORTC.F0==1 &&
PORTC.F1==1))
{
S1=0;
S4=0;
S2=0;
S3=0;
}
}

HARDWARE

HARDWARE

You might also like