Hi everybody, I am using an Arduino Uno, here is my code:
#include "DualVNH5019MotorShield.h"
DualVNH5019MotorShield md;
void setup() {
Serial.begin (115200);
Serial.println("Dual VNH5019 Motor Shield");
}
void loop()
{
int now=6000;
Serial.print("BEGINNING CYCLE ");
{
if (1000 <= now <= 4000){
Serial.print(" now Value Branch1: ");
Serial.println(now);
}
else {
Serial.print("now Value Branch2: ");
Serial.println(now);
}
delay(1000);
}
}
I am having trouble with using "if else" clauses, with multiple branches; the code I am including is a simple way to expose the problem; when running the program the condition " if (1000 <= now <= 4000)" is just ignored and the output in the serial port (PC screen) is:
Dual VNH5019 Motor Shield
BEGINNING CYCLE now Value Branch1: 6000
BEGINNING CYCLE now Value Branch1: 6000
BEGINNING CYCLE now Value Branch1: 6000
.
.
.
Instead of having an output from Branch 2, as expected.
Why is this happening???
I would appreciate any help and/or suggestion to fix the code.
Will