Thanks for the response racemaniac. At this point I can't remember everything that I've tried but I've been working with a lot of different conditional statements. I tried an if() statement but that didn't do anything. Most of them don't do anything except continue to blink all 3 LEDs. If something changes, what seems to always happen is:
a. One LED will blink at random.
b. All 3 will blink.
c. 1/3 of the LEDs will turn off.
d. All 3 will turn off.
e. Loop.
Here is the last attempt I made, which resulted in all 3 LEDs continually blinking:
const int pin2 = 2;
const int pin3 = 3;
const int pin4 = 4;
int maxnum = 3; //Blink LED 3 times
int count = 0; //Blink counter
int ranNum;
int ranDel;
long timestamp = 0; // long is a much larger integer
boolean ledState = LOW;
int delayLength = 500; // how long between intervals
void setup() {
randomSeed(analogRead(0));
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
Serial.begin(9600);
}
void loop() {
// basic timer
if ( (millis() - timestamp > delayLength) && (count < maxnum) ) {
// half a s second has passed, do something
ledState = !ledState; // toggles the ledState between true/false
digitalWrite(pin2, ledState); // make the led change
digitalWrite(pin3, ledState);
digitalWrite(pin4, ledState);
timestamp = millis();
Serial.println(timestamp);
count=0; }
else {
//light up one LED at random
ranNum=random(2,5);
delay(500);
digitalWrite(ranNum, HIGH);
delay(1000);
digitalWrite(ranNum, LOW);
delay(2000);
count++; }
}
The main problem I'm having is trying to get the 3 LEDs to blink 3 times, stop, have only one LED light up up at random, and repeat. This wouldn't be an issue if I could use delays but I can't use delays as it causes other problems so I'm trying to stick with millis. The ultimate goal is to replicate the rock, paper, scissors game. So the 3 blinks is how much time the player will have to make their move. The random blink will be the machine's move. On the other side is 3 LEDs that will be controlled by the player with a slide potentiometer to position their LED to either the rock, paper or scissor icons.
I hope this helps or provides some context. I feel like I'm missing something very obvious.