C++ problem with Codevision

Thread Starter

frogacult

Joined Apr 30, 2008
27
I'm trying to program AVR STK500 with Codevision (c++) & run it with AVRstudio4.
I want to make this : When PIND.0 is set then the outpout PORTB.1 & PORTB.4 are "1" and a message in lcd,when it is "0" nothing happens.
i write the code and it works. (PIND.0 is connnected with a switch).
if i connect a second switch to input PIND.1 and program it when it is set "1"
to do something and when it is "0" something else then nothing works right
and the 2 occasions are on always or works the one input or the other.
i've attached t he code below.
There is another way that i wouldn't use the "if" command because i think this makes the problems
 

Attachments

hgmjr

Joined Jan 28, 2005
9,027
Rich (BB code):
while (1)
{   // Added this brace...
      if(PIND.0==0)         //Input. Airflow sensor 
       {
        air_flow_error();
       }
       else
       {
        air_flow_ok();
       } 
 
       if(PIND.1==0)  //Input.Thermal sensor
       {
        low_temp();
       } 
       else
       {
        high_temp();
       }
 
       if(PIND.0==0&&PIND.1==0)
       {
        air_flow_error();
        low_temp();
       } 
 
       else if(PIND.0==0&&PIND.1==1)
       {
        air_flow_error();
        high_temp();
       }
 
       else if(PIND.0==1&&PIND.1==0)
       {
        air_flow_ok();
        low_temp();
       }
 
       else if(PIND.0==1&&PIND.1==1)
       {
        air_flow_ok();
        high_temp();
}  //Added this brace....
 
}
I have bolded the braces that mark44 has been trying to get you to add.

hgmjr
 
Top