if (blink_status ==1){ //If led is bliking, stop it
P1OUT &= ~ 0x01; // Turn Led off
blink_status=0;
}else
blink_status=1;
}
Could anybody explain the logic please...
if (blink_status ==1){ //If led is bliking, stop it
P1OUT &= ~ 0x01; // Turn Led off
blink_status=0;
}else
blink_status=1;
}
Could anybody explain the logic please...
>>P1OUT &= ~ 0x01
I suspect P1OUT is an LED port address, and as the comment says it is turning off the bit.
Try reading about bitwise operators, that will clear things up for you.
I understand the the bitwise operation... no issues abt that..
but with the "if.. else" statement.... why is the condition same for both if and else....
The else doesn't have a condition, but the syntax error could lead you to think that. The code should be:
if (blink_status ==1){ //If led is bliking, stop it
P1OUT &= ~ 0x01; // Turn Led off
blink_status=0;
}else{
blink_status=1;
}
blink_status=1 is simply a statement. This code just flips blink_status between 0 and 1.
hmm. .. I got it...
thnks to all suggestions .....
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.