it's working!!
thank you so much everyone for the help! the last code i posted was actually almost good, but there was an "else" missing that i hadn't noticed.
so with this code, i can control the blinking of both leds independent of each other.
thank you so much
here's the code that's working:
int ledPinA = 12;
int ledPinB = 13; // LEDs connected to digital pins 12 and 13
int potA = 0;
int potB = 1; //pots
int ldrA = 3;
int ldrB = 4; //ldrs - use 2.2k ohm resistors (red red red gold)
int valueA = LOW;
int valueB = LOW; // previous value of the LED
int lightvalA, lightvalB;
long previousMillisA, previousMillisB; // will store last time LED was updated
long intervalA, intervalB; // interval at which to blink (milliseconds)
void setup()
{
Serial.begin(9600);
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT); // sets the digital pins as outputs
}
void loop()
{
// check to see if it's time to blink the LED; that is, is the difference
// between the current time and last time we blinked the LED bigger than
// the interval at which we want to blink the LED.
intervalA = analogRead(potA);
intervalB = analogRead(potB);
lightvalA = analogRead(ldrA);
lightvalB = analogRead(ldrB);
if (intervalA > 1020)
{
valueA = LOW;
digitalWrite (ledPinA, valueA);
}
else if (intervalA < 5)
{
valueA = HIGH;
digitalWrite (ledPinA, valueA);
}
else if (millis() - previousMillisA > intervalA) {
previousMillisA = millis(); // remember the last time we blinked the LED
// if the LED is off turn it on and vice-versa.
if (valueA == LOW)
valueA = HIGH;
else
valueA = LOW;
digitalWrite(ledPinA, valueA);
}
if (intervalB > 1020)
{
valueB = LOW;
digitalWrite (ledPinB, valueB);
}
else if (intervalB < 5)
{
valueB = HIGH;
digitalWrite (ledPinB, valueB);
}
else if (millis() - previousMillisB > intervalB) {
previousMillisB = millis(); // remember the last time we blinked the LED
// if the LED is off turn it on and vice-versa.
if (valueB == LOW)
valueB = HIGH;
else
valueB = LOW;
digitalWrite(ledPinB, valueB);
}
Serial.println (lightvalA);
}