Explorer les Livres électroniques
Catégories
Explorer les Livres audio
Catégories
Explorer les Magazines
Catégories
Explorer les Documents
Catégories
Afficheur LCD
Exercice 1 :
Code du programme
sbit LCD_RS at LATB0_bit;
// direction de la broche RS
// direction de la broche E ou EN
LCD_init();
// initialisation
LCD_cmd(_LCD_clear);
LCD_cmd(_LCD_CURSOR_OFF);
// désactiver le curseur
while(1)
LCD_out(1,3,"ISET DJERBA");
delay_ms(500);
LCD_cmd(_LCD_clear);
// effacer le messge
delay_ms(500);
// durée de disparaitre
}
Réalisation sur ISIS :
Exercice 2 :
Code du programme :
sbit LCD_RS at LATB0_bit;
// direction de la broche E ou EN
void main()
LCD_init();
// initialisation
LCD_cmd(_LCD_clear);
LCD_cmd(_LCD_CURSOR_OFF);
// désactiver le curseur
while(1)
LCD_out(1,3,"ISET DJERBA");
LCD_out(2,6,"L3MT2");
delay_ms(500);
// durée d'affichage 500 ms
LCD_cmd(_LCD_clear);
// effacer le messge
delay_ms(500);
// durée de disparaitre
}
}
}
Réalisation sur isis :
LCD1
LM016L
U1
2 15
RA0/AN0/C1IN- RC0/T1OSO/T13CKI
VDD
VSS
VEE
3 16
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E RA1/AN1/C2IN- RC1/T1OSI/CCP2B
4 17
RA2/AN2/C2IN+/VREF-/CVREF RC2/CCP1/P1A
5 18
RA3/AN3/C1IN+/VREF+ RC3/SCK/SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
6 23
RA4/T0CKI/C1OUT RC4/SDI/SDA
7 24
RA5/AN4/SS/HLVDIN/C2OUT RC5/SDO
14 25
RA6/OSC2/CLKO RC6/TX/CK
13 26
RA7/OSC1/CLKI RC7/RX/DT
33 19
RB0/AN12/FLT0/INT0 RD0/PSP0
34 20
RB1/AN10/INT1 RD1/PSP1
35 21
RB2/AN8/INT2 RD2/PSP2
36 22
RB3/AN9/CCP2A RD3/PSP3
37 27
RV1 38
RB4/KBI0/AN11 RD4/PSP4
28 R2 R3
RB5/KBI1/PGM RD5/PSP5/P1B
1k 39 29
RB6/KBI2/PGC RD6/PSP6/P1C 10k 10k
40 30
RB7/KBI3/PGD RD7/PSP7/P1D
8
RE0/RD/AN5
9
RE1/WR/AN6
10
RE2/CS/AN7
1
RE3/MCLR/VPP
PIC18F4520
R1
10k
LCD1
LM016L
U1
2 15
RA0/AN0/C1IN- RC0/T1OSO/T13CKI
VDD
VSS
VEE
3 16
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
RA1/AN1/C2IN- RC1/T1OSI/CCP2B
E
4 17
RA2/AN2/C2IN+/VREF-/CVREF RC2/CCP1/P1A
5 18
RA3/AN3/C1IN+/VREF+ RC3/SCK/SCL
11
1
2
3
4
5
6
7
8
9
10
12
13
14
6 23
RA4/T0CKI/C1OUT RC4/SDI/SDA
7 24
RA5/AN4/SS/HLVDIN/C2OUT RC5/SDO
14 25
RA6/OSC2/CLKO RC6/TX/CK
13 26
RA7/OSC1/CLKI RC7/RX/DT
33 19
RB0/AN12/FLT0/INT0 RD0/PSP0
34 20
RB1/AN10/INT1 RD1/PSP1
35 21
RB2/AN8/INT2 RD2/PSP2
36 22
RB3/AN9/CCP2A RD3/PSP3
37 27
RV1 38
RB4/KBI0/AN11 RD4/PSP4
28 R2 R3
RB5/KBI1/PGM RD5/PSP5/P1B
1k 39 29
RB6/KBI2/PGC RD6/PSP6/P1C 10k 10k
40 30
RB7/KBI3/PGD RD7/PSP7/P1D
8
RE0/RD/AN5
9
RE1/WR/AN6
10
RE2/CS/AN7
1
RE3/MCLR/VPP
PIC18F4520
R1
10k
Exercice 4 :
Code du programme
#define bpd button(&PORTD,0,20,1)
// direction de la broche RS
// direction de la broche E ou EN
LCD_init();
// initialisation
LCD_cmd(_LCD_clear);
LCD_cmd(_LCD_CURSOR_OFF);
// désactiver le curseur
while(1)
if(bpd)
while(bpd);
LCD_out(1,3,msg1);
LCD_out(2,6,msg2);
LCD_cmd(_LCD_SHIFT_RIGHT);
//décalage à droite
}
if(bpg)
while(bpg);
LCD_out(1,3,msg1);
LCD_out(2,6,msg2);
LCD_cmd(_LCD_SHIFT_LEFT);
//decalage à gauche
// direction de la broche RS
// direction de la broche E ou EN
char msg[128];
int count ;
LCD_init();
// initialisation
LCD_cmd(_LCD_clear);
LCD_cmd(_LCD_CURSOR_OFF);
// désactiver le curseur
TRISB=0;
TRISC=0;
TRISD=0Xff;
LCD_out(1,1,"compteur :0->");
LCD_out(2,1,"decompteur:128<-");
delay_ms(1000);
// durée d'affichage
LCD_cmd(_LCD_clear);
while(1)
if(bpc)
while(bpc);
if (count==128)
count=0;
else
count++;
// compteur
LCD_out(1,3,msg1);
inttostr(count,msg);
LCD_out(2,6,msg);
if(bpd)
while(bpd);
if (count==0)
count=128;
else
count--;
// décompteur
LCD_out(1,3,msg2);
inttostr(count,msg);
LCD_out(2,6,msg);
LATC=count;