#define Tank1_Top 21
#define Tank1_Bottom 19
#define Tank2_Top 18
#define Tank2_Bottom 5
#define General_Motor 2
#define OneHP_Motor 15
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Tank1_Top, INPUT_PULLUP);
pinMode(Tank1_Bottom, INPUT_PULLUP);
pinMode(Tank2_Top, INPUT_PULLUP);
pinMode(Tank2_Bottom, INPUT_PULLUP);
pinMode(General_Motor, OUTPUT);
pinMode(OneHP_Motor, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int Tank1Top_level = digitalRead(Tank1_Top);
int Tank1Bottom_level = digitalRead(Tank1_Bottom);
int Tank2Top_level = digitalRead(Tank2_Top);
int Tank2Bottom_level = digitalRead(Tank2_Bottom);
if (Tank1Top_level == 0 && Tank1Bottom_level == 0) {
digitalWrite(General_Motor, LOW);
digitalWrite(OneHP_Motor, LOW);
Serial.println("General Motor:OFF");
Serial.println("OneHP Motor:OFF");
}
else if (Tank1Bottom_level == 1 && Tank2Bottom_level == 0){
digitalWrite(General_Motor, HIGH);
digitalWrite(OneHP_Motor, LOW );
Serial.println("General Motor:ON");
Serial.println("OneHP Motor:OFF");
}
else if (Tank1Bottom_level == 1 && Tank2Bottom_level == 1){
digitalWrite(General_Motor, LOW);
digitalWrite(OneHP_Motor, HIGH);
Serial.println("General Motor:OFF");
Serial.println("OneHP Motor:ON");
}
else{
Serial.println("No operation");
}
delay(1000);
}