Hello
im new to programming and im sorry for the stupid question but .
i have 3 led on my circuit
1 . first led is on/off indicator for system
2. blue led
3. red led
im trying to create a condition that when on/off led is set to LOW the other led cannot turn on unless
the on/off led is set to high via serial command
thank you guys
elidor
//Program by Jeremy Blum
//www.jeremyblum.com
//Uses commands from computer to control arduino
int ledPin = 13;
int coolPin = 12;
int heatPin = 11;
void setup()
{
//Create Serial Object
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(coolPin, OUTPUT);
pinMode(heatPin, OUTPUT);
}
void loop()
{
//Have the arduino wait to receive input
while (Serial.available() == 0);
//Read the Input
int val = Serial.read() - '0';
if (val == 1)
{
Serial.println("Led is On");
digitalWrite(ledPin, HIGH);
}
else if (val == 0)
{
Serial.println("Led is Off");
digitalWrite(ledPin, LOW);
digitalWrite(coolPin, LOW);
digitalWrite(heatPin, LOW);
}
// condition if led pin off nothing else is on
if (val ==2 )
{
Serial.println("cool") ;
digitalWrite(heatPin, LOW) ;
digitalWrite(coolPin, HIGH) ;
}
else if (val==3)
{
Serial.println("heat");
digitalWrite(coolPin, LOW);
digitalWrite(heatPin, HIGH);
}
}
TheUnnamedCircuit.ino (1.46 KB)