- Fri Feb 02, 2018 7:34 pm
#198145
Hi there, I have written written this code:
_______________________________________________________________
_______________________________________________________________
if ((distance < 50)&&(currentState=0))
{
currentState = 1;
}
else if ((distance < 50)&&(currentState=1))
{
currentState = 0;
_______________________________________________________________
_______________________________________________________________
What I am trying to say is if "distance" is less than 50, then turn "currentState" to 1 if it was already 0 and turn it to 0 if it was already 1.
Clearly, it is wrong because it's not working.
Can someone help me?
Thanks,
Ardalan
_______________________________________________________________
_______________________________________________________________
if ((distance < 50)&&(currentState=0))
{
currentState = 1;
}
else if ((distance < 50)&&(currentState=1))
{
currentState = 0;
_______________________________________________________________
_______________________________________________________________
What I am trying to say is if "distance" is less than 50, then turn "currentState" to 1 if it was already 0 and turn it to 0 if it was already 1.
Clearly, it is wrong because it's not working.
Can someone help me?
Thanks,
Ardalan