Forum Replies Created
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
OmekenParticipant
I mean changing RD1_bit = 0; to TRISD = ;
OmekenParticipantI have rectified the problem, the design is now working . I changed to
RD0_bit = 0;
RD1_bit =0 ; to TRISD = 0;- This reply was modified 4 years, 8 months ago by Ligo George.
OmekenParticipantI am with LM35, LCD 16*2, and 16F877A. I want to use different value (read temperature and reference temperature) of the temperature to on or off the two LED. The code is only controlling one LED RD0.
// LCD module connections sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; // End LCD module connections unsigned int read_value=0, ref_value; unsigned int value=0; unsigned int temp; char aux[7]; void main() { RD0_bit = 0; RD1_bit =0; ADCON1 = 0x00; // All channels are config as analog I/p. ADC_Init(); Lcd_Init(); // Initialize LCD Lcd_cmd(_lcd_clear); Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_out(1,3,"Temperature:"); LCD_Out(2,1,"Eff: Ref:"); while(1) { read_value = Adc_Get_Sample(2)>>2; ref_value = ADC_Get_Sample(4)>>2; if (read_value < ref_value) { PORTD.RD0 = 1; if (read_value > ref_value) PORTD.RD1 = 1; else PORTD.RD1 = 0; PORTD.RD0 = 0; } value = (unsigned int) read_value * (500./255); // Resolution for 5 volts, 8 bits ByteToStr(value,Ltrim(aux)); LCD_Out(2,5, aux); //shows reading temperature value = (unsigned int) ref_value * (500./255); ByteToStr(value,Ltrim(aux)); LCD_Out(2,13, aux); //shows reference temperature delay_ms(50); } }
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)