hello ,
I am new to this forum and I do not speak much anglai, here is my setup is a pic 16f877 connected a variable resistor 2 and 2 and a bargraph LCD 16 * 2 to display the liquid level,
and the code :
i need the program code for lcd 16*2 to show the result please help me
I am new to this forum and I do not speak much anglai, here is my setup is a pic 16f877 connected a variable resistor 2 and 2 and a bargraph LCD 16 * 2 to display the liquid level,
and the code :
Rich (BB code):
unsigned int niv_bac1;
unsigned int niv_bac2;
unsigned char i,j;
unsigned int niveaux[8] = {127, 254, 382, 510, 638, 776, 894, 1022};
unsigned char VnDuNiveau(unsigned int val) {
unsigned char i = 0;
while (i < sizeof(niveaux)) {
if (val < niveaux)
return i;
else i++;
}
}
void main() {
// Configuration des pins 2 et 3 en analogique
TRISA = 0xFF; // programmtion du PORTA en entrée
TRISB = 0; // programmtion du PORTB en sortie
TRISC = 0; // programmtion du PORTC en sortie
TRISD = 0; // programmtion du PORTD en sortie
OPTION_REG.NOT_RBPU = 0;
do {
adcon0=0x80;
niv_bac1= Adc_Read(0); // lecture du niveau de fluide du bac1
//portB=niv_bac1>>2; //Affichage en binaire du niveau de fluide
j= VnDuNiveau(niv_bac1);
switch ( j ) {
case 0:
// Code
portB = 0x01;
break;
case 1:
// Code
portB = 0x03;
break;
case 2:
// Code
portB = 0x07;
break;
case 3:
// Code
portB = 0x0F;
break;
case 4:
// Code
portB = 0x1F;
break;
case 5:
// Code
portB = 0x3F;
break;
case 6:
// Code
portB = 0x7F;
break;
case 7:
// Code
portB = 0xFF;
break;
}
adcon0=0x88; //du bac1 sur le portB
niv_bac2= Adc_Read(1); // lecture du niveau de fluide du bac2
//PORTC = niv_bac2>>2; //Affichage en binaire du niveau de fluide
//du bac2 sur le portC
j= VnDuNiveau(niv_bac2);
switch ( j ) {
case 0:
// Code
portC = 0x01;
break;
case 1:
// Code
portC = 0x03;
break;
case 2:
// Code
portC = 0x07;
break;
case 3:
// Code
portC = 0x0F;
break;
case 4:
// Code
portC = 0x1F;
break;
case 5:
// Code
portC = 0x3F;
break;
case 6:
// Code
portC = 0x7F;
break;
case 7:
// Code
portC = 0xFF;
break;
}
} while(1);
}
i need the program code for lcd 16*2 to show the result please help me