Documente Academic
Documente Profesional
Documente Cultură
BRIZ BSECE-IV
CODE: (08206)- ECE 542/L
Laboratory Experiment 4
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1, "Digital");
Lcd_Out(2,1, "Thermometer");
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1, "Temperature :");
Lcd_Chr(2,8,223);
Lcd_Chr(2,9,'C');
temperature = 0;
do
{
temperature = ADC_Read(0);
mV = temperature * 5000.0/1024.0;
mV = mV/10.0;
FloatToStr(mV, txt);
Delay_ms(500);
}
while(1);
}
LABORATORY DESIGN 4
float mV;
int x = 0;
void main()
{
ADCON1 = 0x0E;
PORTA = 0;
TRISA = 0x01;
PORTB = 0;
TRISB = 0;
ADC_Init();
Lcd_init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1,Ltrim("Digital"));
Lcd_Out(2, 1, Ltrim("Thermometer"));
Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1, Ltrim("Temp:"));
Lcd_Chr(1,12,Ltrim(223));
Lcd_Chr(1,13,Ltrim('C'));
temperature = 0;
do
temperature = ADC_Read(0);
FloatToStr(mV, Ltrim(txt));
txt[4] = 0;
Lcd_Out(1, 7, Ltrim(txt));
if(x == 1)
PORTB = 0x02;
v1 = mV;
if(x == 2)
PORTB = 0b00000110;
v2 = mV;
if(x == 3)
PORTB = 0b000001110;
v3 = mV;
if(x == 4 )
PORTB = 0b000111110;
v4 = mV; }
if(x == 5)
PORTB = 0b00111110;
v5 = mV;
}
if(x == 6)
Lcd_Cmd(_LCD_CLEAR);
v6 = (v1 + v2 + v3 + v4 + v5)/5;
FloatToStr(v6,txt1);
txt1[4] = 0;
Lcd_out(2,3,txt1);
Lcd_Chr(2,8,Ltrim(223));
Lcd_Chr(2,9,Ltrim('C'));
delay_ms(500);
x++;
while(1);