This following code is using the program MikroC on the PIC16F877A. PIC16F877A interface potentiometer using MikroC for PIC code. 0% to 100% rotation display on LCD. How do I modify this code to use on the PIC16F1829 on MPLABX? // Lcd pinout settings sbit LCD_RS at RC0_bit; sbit LCD_EN at RC1_bit; sbit LCD_D7 at RD1_bit; sbit LCD_D6 at RD0_bit; sbit LCD_D5 at RC3_bit; sbit LCD_D4 at RC2_bit; // Pin direction sbit LCD_RS_Direction at TRISC0_bit; sbit LCD_EN_Direction at TRISC1_bit; sbit LCD_D7_Direction at TRISD1_bit; sbit LCD_D6_Direction at TRISD0_bit; sbit LCD_D5_Direction at TRISC3_bit; sbit LCD_D4_Direction at TRISC2_bit; float pot; char pot1[4]; void main() { LCD_init(); Delay_ms(1000); ADC_init(); Delay_ms(1000); Lcd_Cmd(_LCD_CURSOR_OFF); Delay_ms(100); Lcd_Cmd(_LCD_CLEAR); Delay_ms(100); while(1) { pot = ADC_Read(0); Delay_ms(100); if(( potGT0 ) && ( potLT50 )) { LCD_OUT(1,1,"0 %"); Delay_ms(100); } else if(( potGT50 ) && ( potLT100 )) { LCD_OUT(1,1,"10 %"); Delay_ms(100); } else if(( potGT100 ) && ( potLT200 )) { LCD_OUT(1,1,"20 %"); Delay_ms(100); } else if(( potGT200 ) && ( potLT300 )) { LCD_OUT(1,1,"30 %"); Delay_ms(100); } else if(( potGT300 ) && ( potLT400 )) { LCD_OUT(1,1,"40 %"); Delay_ms(100); } else if(( potGT400 ) && ( potLT500 )) { LCD_OUT(1,1,"50 %"); Delay_ms(100); } else if(( potGT500 ) && ( potLT600 )) { LCD_OUT(1,1,"60 %"); Delay_ms(100); } else if(( potGT600 ) && ( potLT700 )) { LCD_OUT(1,1,"70 %"); Delay_ms(100); } else if(( potGT700 ) && ( potLT800 )) { LCD_OUT(1,1,"80 %"); Delay_ms(100); } else if(( potGT800 ) && ( potLT900 )) { LCD_OUT(1,1,"90 %"); Delay_ms(100); } else if( potGT900 ) { LCD_OUT(1,1,"100%"); Delay_ms(100); } } }
This following code is using the program MikroC on the PIC16F877A. PIC16F877A interface potentiometer using MikroC for PIC code. 0% to 100% rotation display on LCD. How do I modify this code to use on the PIC16F1829 on MPLABX?
// Lcd pinout settings
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D7 at RD1_bit;
sbit LCD_D6 at RD0_bit;
sbit LCD_D5 at RC3_bit;
sbit LCD_D4 at RC2_bit;
// Pin direction
sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D7_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC2_bit;
float pot;
char pot1[4];
void main() {
LCD_init();
Delay_ms(1000);
ADC_init();
Delay_ms(1000);
Lcd_Cmd(_LCD_CURSOR_OFF);
Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(100);
while(1)
{
pot = ADC_Read(0);
Delay_ms(100);
if(( potGT0 ) && ( potLT50 ))
{
LCD_OUT(1,1,"0 %");
Delay_ms(100);
}
else if(( potGT50 ) && ( potLT100 ))
{
LCD_OUT(1,1,"10 %");
Delay_ms(100);
}
else if(( potGT100 ) && ( potLT200 ))
{
LCD_OUT(1,1,"20 %");
Delay_ms(100);
}
else if(( potGT200 ) && ( potLT300 ))
{
LCD_OUT(1,1,"30 %");
Delay_ms(100);
}
else if(( potGT300 ) && ( potLT400 ))
{
LCD_OUT(1,1,"40 %");
Delay_ms(100);
}
else if(( potGT400 ) && ( potLT500 ))
{
LCD_OUT(1,1,"50 %");
Delay_ms(100);
}
else if(( potGT500 ) && ( potLT600 ))
{
LCD_OUT(1,1,"60 %");
Delay_ms(100);
}
else if(( potGT600 ) && ( potLT700 ))
{
LCD_OUT(1,1,"70 %");
Delay_ms(100);
}
else if(( potGT700 ) && ( potLT800 ))
{
LCD_OUT(1,1,"80 %");
Delay_ms(100);
}
else if(( potGT800 ) && ( potLT900 ))
{
LCD_OUT(1,1,"90 %");
Delay_ms(100);
}
else if( potGT900 )
{
LCD_OUT(1,1,"100%");
Delay_ms(100);
}
}
}

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









