Driving me crazy- how do you do this:
if(condition) { PORTA.i = 1; } ELSE { PORTA.i =0; }
i++;
ie I want to loop through each of the pins on portA and turn them on or off depending on the condition which uses data in array
Thanks
output to port.fx
- tihomir.losic
- mikroElektronika team
- Posts: 2138
- Joined: 02 Dec 2009 14:16
- Location: Serbia
- Contact:
Re: output to port.fx
Hello,
the syntax of the if statement is:If expression evaluates to true, statement1 executes. If expression is false, statement2 executes.
The expression must evaluate to an integral value; otherwise, the condition is ill-formed. Parentheses around the expression are mandatory.
The else keyword is optional, but no statements can come between if and else.
Best regards,
Losic Tihomir
the syntax of the if statement is:
Code: Select all
if (expression) statement1 [else statement2]
The expression must evaluate to an integral value; otherwise, the condition is ill-formed. Parentheses around the expression are mandatory.
The else keyword is optional, but no statements can come between if and else.
Best regards,
Losic Tihomir
mikroElektronika [Support team]
Re: output to port.fx
Thanks but it's not the IF statement I need help with- it is the PORTA command: how to scroll through each pin using the variable i
Re: output to port.fx
In the first place if your i++ is in an endless loop your i will be very high in matter of us.
You should write something like this:
your condition can be a button press for example.
Regards Balazs.
You should write something like this:
Code: Select all
void main(){
int i=0;
while(1){
if(condition)
{ PORTA.i = 1;}
ELSE
{ PORTA.i =0;}
i++;
Delay_ms(500);
if(i>7)i=0;
}
}
Regards Balazs.
Re: output to port.fx
No the ONLY problem I have is with the PORTA.i line! This does not compile.
I want to change i (using the loop) to scroll through the pins of PORTA. IF's DO's and all other coding is fine.
Thanks.
I want to change i (using the loop) to scroll through the pins of PORTA. IF's DO's and all other coding is fine.
Thanks.