PINA.0 is used to reads specific bits of the port in codevisionAVR, the program above seems to be from winAVR (gcc)
read=PINA; will read the value of the port to the variable input.
I don't agree with the case method in this because you are scanning for only one single triggered pin ,but these could be two alarms at the same time.
you are scanning for values 1,2,4 but if 1 and 2 are both 1 you will not be able to detect it because it will be value 3, the same happens with any other combination.
You should use
Code:
if(read&(0x1)) dis1();
if(read&(0x2)) dis2();
if(read&(0x4)) dis3();
so that all the alarms are triggered individually if the input changes.
I also don't agree with the way you use your leds, you are assigning a value to the entire port which means that you will turn off any led that is already on.
You should use logic "OR" to light the led and logic "AND" to turn them off
Code:
PORTD|=0x1; // to light led 1
PORTD|=0x2; // to light led 1
PORTD|=0x4; // to light led 3
PORTD&=(~0x1); // turn off led 1
PORTD&=(~0x2); // turn off led 2
PORTD&=(~0x4); // turn off led 3
//or
PORTD&=(~0x7); // turn off leds 1,2,3 at once
The above will only work if your sensors have a digital output, if not you need to use the a/d converter to read any analog voltage and react depending on the value
hamidmoallemi is corrected, LM35 output is an analog voltage so you need to use the a/d converter to read it.
Alex.