Hey everybody,
so recently i have been working on a project that tells you where is the acclemometter position using its x,y and z readins , but i have a problem it seams that the arduino just skips the if commands and serial prints automatically (and no the values is not the same as in the boolean and if commands when the serial.print command engages).
it just spams the serial monitor with the serial.print command that should be done after checking for the values in the if statement but i guess it doesnt check.
const int xpin = A3;
const int ypin = A2;
const int zpin = A1;
void setup() {
Serial.begin(9600);
}
void loop() {
int x = analogRead(xpin);
int y = analogRead(ypin);
int z = analogRead(zpin);
if (x<370||x>335 ){
if (y<330||y>320){
if (z<411||z>404){
Serial.print("position: middle");
}
}
}
}
also i have tried this
const int xpin = A3;
const int ypin = A2;
const int zpin = A1;
void setup() {
Serial.begin(9600);
}
void loop() {
int x = analogRead(xpin);
int y = analogRead(ypin);
int z = analogRead(zpin);
if (x<480||x>350 && y<340||y>310 && z<410||z>380) {
Serial.print("position: middle");
}
}