#include <project.h>
int main()
{
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
int16 res;
float vol;
int16 value;
char tstr;
ADC1_Start();
LCD1_Start();
LCD1_ClearDisplay();
ADC1_StartConvert();
LCD1_Position(0,0);
LCD1_Position(1,8);
for(;;)
{
while(ADC1_IsEndConversion(ADC1_WAIT_FOR_RESULT)==0);
res=ADC1_GetResult16();
vol=ADC1_CountsTo_Volts(res);
sprintf(tstr,"%+1.4f",vol);
value=(int)80*vol/5.0;
if(Pin_2_Read()==0)
{
LCD1_Position(0,0);
LCD1_PrintString("Measured Voltage is:");
LCD1_Position(1,0);
LCD1_PrintString(tstr);
LCD1_PrintString(" V ");
}
else
LCD1_DrawHorizontalBG(1,0,80,value);
/* Place your application code here. */
}
}
/* [] END OF FILE */ |