.


:




:

































 

 

 

 


. 1. ѳ MPLAB IDE




1. ѳ MPLAB IDE.

2. , PIC.

3. MPLAB IDE, ѳ.

4. .

5. .

.

:

. ˳ . ˳ . ( )

#define XTAL FREQ 4MHZ

#include<pic.h> //

#include<stdlib.h> //

#include<delay.>//

// 200

#include<delay.h>

 

unsigned char knop;//

unsigned char dat;

unsigned char kn;

unsigned char tdat;

unsigned char r;

unsigned char ;

unsigned char m;

unsigned char time;

void read (unsigned char knop);// read

main()

{

=1;

ADCON1=0b00000110;/ /

TRISA=0b111111;

TRISB=0;

TRISC=0b10000000;

TRISD=0b11111000;

PORTB=0;

PORTC=0;

PORTD=0b00000100;

SPBRG=99;

TXSTA=0b00100100;//

RCSTA=0b10010000;//

knop=0b00001000;//

read(knop);

while(1)

{

while ((knop=(PORTD&120))==120);//

knop=(knop^120);//

://120=1111000

dat=(PORTA^15);//

://30=11110

dat=(dat<<3);// dat 3

if (dat<knop) PORTD=(PORTD2); //

else PORTD=(PORTD4); //

read(knop);//

 

}// while(1)

}// main()

void read (unsigned char knop)//

{

while(1)

{

while((tdat=(PORTA&15))==15);// -

;// 30=11110

dat=(tdat^15);//

dat=(dat<<2);// dat 1

if (dat!=0);// dat ,

{PORTB=dat;

TXREG=dat;//

TXEN=1;//

dat=(dat<<1);// dat 2

}

if ((=(dat-knop))==0);// (dat-knop)=0

{ //

PORTD=(PORTD&248); //248=10000000

PORTB=(PORTB&60); // 60=111100 break;

}

r=(abs(dat-knop));// (dat-knop)=8

if (r==8 r==16 r==32) // r=8 r=16 r=32

{ time=0; //

while(time!=10) //10*100=1000mS=1S

{ //

DelayMs(100);// 100 //

time++; //

} //

PORTB=(PORTB1); //16 32

}

}

knop=0;

=1;

return; //

}





:


: 2015-05-06; !; : 324 |


:

:

, .
==> ...

1500 - | 1408 -


© 2015-2024 lektsii.org - -

: 0.006 .