How to make LEDs blink when three in a row

So I'm making a tic-tac-toe game and I'm using RGB LEDs and push buttons to do it. I was wondering how I can make the three lights that are in a row blink. I just simply didn't know how to code this.

So if the red pin on the first three RGB LEDs is lit up I want those three to blink until the arduino is reset

those three pins are

const int RED_PIN1 = 22;
const int RED_PIN2 = 28;
const int RED_PIN3 = 34;

the code is below in my reply in an attachment, sorry i forgot to put it here.

You'll have to write some code that goes with the code you have that does that. For some odd reason you thought we could figure out how to add something to your code with only the pin numbers to go on. What were you thinking?

Sorry I forgot, my code is attached to his reply as it is too long to put in this reply. It’s a .ino file.

UINO_PROJECT.ino (10.5 KB)

if ((RED_PIN1, HIGH) && (RED_PIN2, HIGH) && (RED_PIN3, HIGH)) {

    //something here that causes those three pins in the rgb leds to blink until the arduino is reset or unplugged

  }

that is as far as I got. I don't know what to put into the if function or if that's even the right approach

(RED_PIN1, HIGH)

What's that supposed to be? Did you mean to use digitalRead?

I'm a beginner so I'm not very good at this at all. I'm trying to say thats if RED_PIN1, RED_PIN2, and RED_PIN3 are lit up then I want all three of them to blink but I do not know how the code this. My code is attached to my first reply on this post if you didn't see it yet.

[quote author=quinn nolan link=msg=3285258 date=1496369142] I'm a beginner so I'm not very good at this at all. I'm trying to say thats if RED_PIN1, RED_PIN2, and RED_PIN3 are lit up then I want all three of them to blink but I do not know how the code this. My code is attached to my first reply on this post if you didn't see it yet. [/quote]

What rate do wish to blink them? Do you want on to be the same length of time as off? How many minutes do you wish the blinking to continue?

Paul

Blinking is my most basic sketch that I always first load onto a new project to see if the hardware works. It's the standard Blink example, something that just about every coder starts with.

Blinking an LED is easy:

while (true) {
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
}

But: this blinks forever, half second on, half second off, and blocks your sketch from doing anything else. Probably not what you want. So add a counter for starters (how many blinks? On or off at the end?). Make it non-blocking (look for the non-blocking blink example code). Create an array of LEDs to iterate through and switch them on and off together.

wvmarle: Blinking is my most basic sketch that I always first load onto a new project to see if the hardware works. It's the standard Blink example, something that just about every coder starts with.

Blinking an LED is easy:

while (true) {
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
}

But: this blinks forever, half second on, half second off, and blocks your sketch from doing anything else. Probably not what you want. So add a counter for starters (how many blinks? On or off at the end?). Make it non-blocking (look for the non-blocking blink example code). Create an array of LEDs to iterate through and switch them on and off together.

Is it possible to make that infinite blinking loop happen only when certain leds are on?

for example: when the red part of an rgb led in pin 22, the red part of an rgb led in pin 28, and the red part of an rgb led in pin 34 are all on HIGH then they all blink? could you help me code this if it's possible?

Paul_KD7HB: What rate do wish to blink them? Do you want on to be the same length of time as off? How many minutes do you wish the blinking to continue?

Paul

When all three of those LEDs are on HIGH could you make them blink every half second (on and off for 500 ms each) and last for 1-2 min (if not possible for it to be infinite) . Thanks!

[quote author=quinn nolan link=msg=3285331 date=1496377127] Is it possible to make that infinite blinking loop happen only when certain leds are on?

for example: when the red part of an rgb led in pin 22, the red part of an rgb led in pin 28, and the red part of an rgb led in pin 34 are all on HIGH then they all blink? could you help me code this if it's possible? [/quote]

Ever heard of the if statement? Just check using digitalRead() or by checking however you keep track internally that there's a line of three active. Same for the 1-2 minute thing: as I said, add a counter. Count to 60 for a minute, 120 for two minutes, 3600 for an hour. It sounds to me like you have to go and read some basic C tutorials! By the way, how do you even know there's a row of three lit in the first place? There are 8 possibilities in a game of tic tac toe for a row of three to form. Sounds to me like a harder problem than making them blink.