Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming for tgs 2600 in PIC16F877A

Status
Not open for further replies.

mimi22

New Member
As the question above, I facing problem in programming which the LCD nt updating the value of the sensor.What should i do?


if (!sw2) // if button SW2is pressed
{
while(!sw2); // wait until button is released
switch(m) // check what is the current mode, execute the mode
{

case 0 : line_follow(); // mode 1 : line follow
break;
case 1 : wireless_xbee(); // mode 2 : wireless xbee mode
break;
case 2 : analog_sen(); // mode 3 : analog sensor mode
break;
case 3 : gas_sensor(); // mode 4 : gas sensor mode
break;
case 4 : SKPS_PScon(); // mode 5 : PS2 Controller Mode
break;
default : ;

void gas_sensor()
{
unsigned char temp; //declare a temporary variable for reading ADC

//configure ADC
ADCON0=0b10000001; //enable ADC converter module
ADCON1=0b01000100;
lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("Gas Sensor "); //display "Gas Sensor"
temp=read_ad(0); //read AN0 (Gas Sensor)
lcd_goto(20); //set lcd cursor to location 20
send_num(temp); //display the analog value of the gas sensor
}

unsigned char read_ad(unsigned char channel) //fucntion read analog input according to the given channel
{
unsigned char result; //declare a variable call result

ADGO=1; //start ADC convertion
while(ADGO); //wait for ADC convertion to complete
result=ADRESH; //read the result
return result; //return the result

}





But when i load these code..the gas sensor does not update the value even i put smokes on the sensor...what should i do with the coding.Please help.


Report this post
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top