Ha, well this is embarrassing. When I attempted to upload my updated code, i forgot that my Bluetooth receiver was plugged in, and on. That was stopping the code from being uploaded to the Arduino. Thanks to everyone who gave input and suggestions to help my naivety. So here is my present code...
int pinA = 4;
int pinB = 5;
int pinC = 8;
int pinD = 7;
byte command = 0;
const int rHigh = 800;
const int rLow = 200;
int randomPin;
dud
void setup()
{
pinMode(pinA, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0)
{
command = Serial.read();
switch (command)
{
case 1:
if (digitalRead(pinA) == LOW)
{
digitalWrite(pinA, HIGH);
}
else
{
digitalWrite(pinA, LOW);
}
break;
case 2:
if (digitalRead(pinB) == LOW)
{
digitalWrite(pinB, HIGH);
}
else
{
digitalWrite(pinB, LOW);
}
break;
case 3:
if (digitalRead(pinC) == LOW)
{
digitalWrite(pinC, HIGH);
}
else
{
digitalWrite(pinC, LOW);
}
break;
case 4:
if (digitalRead(pinD) == LOW)
{
digitalWrite(pinD, HIGH);
}
else
{
digitalWrite(pinD, LOW);
}
break;
case 5:
do
{
randomPin = random(pinA, pinD + 1);
digitalWrite(randomPin, HIGH);
delay(random(rLow, rHigh));
digitalWrite(randomPin, LOW);
}
while (command == 5);
break;
case 6:
digitalWrite(pinA, HIGH);
digitalWrite(pinB, HIGH);
digitalWrite(pinC, HIGH);
digitalWrite(pinD, HIGH);
break;
case 7:
digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
digitalWrite(pinC, LOW);
digitalWrite(pinD, LOW);
break;
}
}
}
Now the problem I am facing is two-fold. The 'random' portion of the code (case 5) is unstoppable unless I press the reset button. How would i make it so sending a 6 or a 7 would exit the random flashing by turning all relays on or off, but until then, it would stay in a loop? And lastly, for some odd reason case 3 doesn't let me turn off the relay when i send a 3 again, does anyone see a coding error i missed?