Вы находитесь на странице: 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

Вам также может понравиться