I've spent hours on this; it compiles but doesn't give the OUTPUT
Am I doing something wrong with my "if statements"?
Pathetic..... I'm clearly not a professional programmer.
This program raises and lowers a TV in a box. The OUTPUTS are for the L298N (H-bridge), where I have the power for the raising/lowering motor. I'm using the USB from the back of the TV that is 5V when the TV is powered on (as INPUT 1).
Essentially I have 6 states with my INPUTS and need 3 states with my OUTPUTS
Thanks for the help
Tom
This is my program:
/*
TV Power ON
0V to Arduino to say TV up
Limit switch DOWN is 5V (CLOSED)
Limit switch UP is 0V (OPEN)
Then power to L298N
*/
void setup() {
pinMode (1, INPUT); // Power from TV HIGH/LOW
pinMode (3, INPUT); // LIMIT SWITCH UP HIGH/LOW
pinMode (4, INPUT); // LIMIT SWITCH DOWN HIGH/LOW
pinMode(7, OUTPUT); // Direction of motor
pinMode(8, OUTPUT); // Direction of motor
pinMode(9, OUTPUT); // PWM to L298N
}
void loop() {
//IF TV = HIGH (closed)
//LIMIT UP = HIGH (closed)
//LIMIT DOWN = LOW (open)
//then TV STOPS at bottom
if (1==HIGH && 3==HIGH && 4==LOW)
{
digitalWrite(8, LOW);
digitalWrite(7, LOW);
analogWrite(9, 255);
delay (1000);
}
//IF TV = LOW (open)
//LIMIT UP = HIGH (closed)
//LIMIT DOWN = LOW (open)
//power TV off (1), TV GOES UP from the low position
if (1==LOW && 3==HIGH && 4==LOW)
{
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
analogWrite(9, 255);
delay (1000);
}
//then TV continues up (no change in OUTPUT)
if (1==LOW && 3==LOW && 4==LOW)
{
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
analogWrite(9, 255);
delay (1000);
}
//then TV stops at top
if (1==LOW && 3==LOW && 4==HIGH)
{
digitalWrite(8, LOW);
digitalWrite(7, LOW);
analogWrite(9, 255);
delay (1000);
}
//then TV starts coming down
if (1==HIGH && 3==LOW && 4==HIGH)
{
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
analogWrite(9, 255);
delay (1000);
}
//then TV continues down
if (1==HIGH && 3==LOW && 4==LOW)
{
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
analogWrite(9, 255);
delay (1000);
}
}