tom_25
1
Hello i am beginner so, can i have multiple condition?
i create this code for joystik
if (analogRead(VRX) > 0) $$ (analogRead(VRX) < 750) $$ (analogRead(VRY) < 514) $$ (analogRead(VRY) > 250 ) {
mysku_dolu();
}
it is only part but this if have error
LarryD
2
Where did you find the $$ syntax ?
1 Like
bask185
4
$$ is nothing, I think you mean to use &&.
I also recommend some syntax changes for the sake of readability.
Use local variables to store analog sample in. This also runs faster as you take one sample and not two per axis.
int sampleX = analogRead( VRX ) ;
int sampleY = analogRead( VRY ) ;
For complex if statements I also recommend to use more lines and organize it properly.
if( sampleX > 0 && sampleX < 750
&& sampleY > 250 && sampleY < 514 )
{
mysku_dolu();
}
Also, I usually recommend to use constants like, but if these values are only used here... you might as well leave it be.
const int xLow = 0 ;
const int xHigh = 750 ;
const int yLow = 250 ;
const int yHigh = 514 ;
And avoid abreviations. I know nothing of the context, so I cannot start to guess what VRX/VRY means or whatever mysku_dolu
is supposed to mean?
Regards,
Bas
tom_25
6
myska_dolu is my funkcion..
awneil
7
presumably "myska dolu" means something relevant in your language?
system
Closed
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.