Robin2:
What version of the Arduino IDE are you using?
I wonder is this another example of "improvements" to the IDE?
However I can't check because you have not posted your program.
...R
Version 1.6.12
All those different versions confused me a lot as well. Now my software likes to tell me there are new versions available but when i click on that message it says i already have the latest version with new libraries, so why it has to come up with that message?
If you want to see the whole program than it's here..but it's under development...It's for a robot which can do lawnmowing and floorsweeping and has a watercanon and some more features.
I needed the && because when i turn on the switch on the rc transmitter it has to switch some relays. One relay has to be ON for 1 second and than turned off before the next relay is turned on which powers the motor.
That's why i needed this && function, i couldn't get it programmed by if-then-else so started looking for other ways. The Switch'-Case function should also be able to do something like that but with the reference i couldn't get it to work...still don't know why. The reference needs more examples for every new function to learn. I wonder how a kid can ever learn from that, i'm not a nativ english speaker and that's another issue which makes is harder..
const int firstRelay = 9; //actuator up = J9
const int secondRelay = 10; //actuator down = J10
const int thirdRelay = 11; // contact Mower = J7
const int fourthRelay = 6; // Mower Motor ON = J8
int ch1; // Here's where we'll keep our channel values
int m; //m is the mowermode
void setup() {
pinMode(firstRelay, OUTPUT);
pinMode(secondRelay, OUTPUT);
pinMode(thirdRelay, OUTPUT);
pinMode(fourthRelay, OUTPUT);
pinMode(5, INPUT); // 5= pwm-signal in from rc receiver
Serial.begin(9600);
}
void loop() {
ch1 = pulseIn(5, HIGH); // Read the pulse width of pin 5
if(ch1>1600){ //Mower mode is OFF
m=1;
digitalWrite(firstRelay,LOW); //actuator up is ON
digitalWrite(secondRelay,HIGH); //actuator down is OFF
digitalWrite(thirdRelay,HIGH); //mowercontact is OFF
digitalWrite(fourthRelay,HIGH); //Mower Motor OFF
}
if (ch1 < 1400) && (m < 2){ //Mower Mode ON
digitalWrite(firstRelay,HIGH); // actuator UP is OFF
delay(2000);
digitalWrite(secondRelay,LOW); //actuator down is ON
digitalWrite(thirdRelay,LOW); //mowercontact is ON
delay(2000);
digitalWrite(thirdRelay,HIGH); //mowercontact is OFF
digitalWrite(fourthRelay,LOW); //Mower Motor is ON
m=m+1;
}
}