Strobe Light Incorporation Help

Hello,

I have this code for a MOVI Shield and I want to make an led strobe for command 7 (Highlighted in red) I basically want that to loop instead of on then off. I would like it to flash rapidly forever until the command is disabled. How would I do that?

Thanks in advance.

#include <MOVIShield.h>
#include <Servo.h>
//Pins where positive wire of LED connects. (4=Chest Armour Led 7=Eye LED 8=Shield LED)
int led1=4;
int led2=7;
int led3=8;

Servo myservo;
//Define Servo
Servo servo1; //Torso
Servo servo2; //R-Shoulder
Servo servo3; //R-Bicep
Servo servo4; //L-Shoulder
//Servo position in degrees
int servoPos = 0;
int servo1Pos=90;
int servo2Pos=0;
int servo3Pos=30;
int servo4Pos=180;
MOVI recognizer (true); //Get a MOVI object, true enables serial monitor interface, rx and tx for alternate communication pins on AVR architecture boards

void setup()
{
//Define LED pins as outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
//Define servo pins
servo1.attach(3); //attach servo 1 to pin 3
servo2.attach(5);//attach servo 2 to pin 5
servo3.attach(6);//attach servo 3 to pin 6
servo4.attach(9);//attach servo 4 to pin 9

recognizer.init();
recognizer.callSign(F(“Sergey”)); //Train callsign (may take 20 seconds)
recognizer.addSentence(F(“Activate display mode”)); //1 (Turns on lights)
recognizer.addSentence(F(“Activate stealth mode”)); //2 (Turns off lights)
recognizer.addSentence(F(“Shutdown”)); //3 (Turn off all LEDs and puts servos to rest position)
recognizer.addSentence(F(“At ease”)); //4 (Servos go to home postion but LEDs stay on)
recognizer.addSentence(F(“Activate Shield”)); //5 (Turns on LED for Riot Shield)
recognizer.addSentence(F(“Pose”)); //6 (SERGEY strikes a pose)
recognizer.addSentence(F(“Guard Mode”)); //7 (Shield Strobes)
recognizer.train();

}

void loop() {
int res = recognizer.poll();

if (res == 1) {
recognizer.say(“Display mode activated”);
digitalWrite(led1, HIGH); //Turns on LED connected to pin 4
digitalWrite(led2, HIGH); //Turns on LED connected to pin 7
recognizer.ask();
}
if (res == 2) {
recognizer.say(“Stealth mode activatedn”);
//Turns off all LEDs
digitalWrite(led1, LOW); //Turns off LED connected to pin 4
digitalWrite(led2, LOW); //Turns off LED connected to pin 7
digitalWrite(led3, LOW); //Turns off LED connected to pin 8
}
if (res == 3) {
recognizer.say(“Deactivating”);
//Turns off all LEDs
digitalWrite(led1, LOW); //Turns off LED connected to pin 4
digitalWrite(led2, LOW); //Turns off LED connected to pin 7
digitalWrite(led3, LOW); //Turns off LED connected to pin 8
servo1.write(90);// set torso to home/rest position
servo2.write(0);// set R-Shoulder to home/rest position
servo3.write(30);// set R-Bicep to home/rest position
servo4.write(180);//set L-Shoulder to home/rest position
}
if (res ==4) {
recognizer.say(“Yes, commander”);
//Turns off all LEDs
digitalWrite(led1,HIGH); //Turns on LED connected to pin 4
digitalWrite(led2, HIGH); //Turns on LED connected to pin 7
digitalWrite(led3, HIGH); //Turns on LED connected to pin 8
servo1.write(90);// set torso to home/rest position
servo2.write(0);// set R-Shoulder to home/rest position
servo3.write(30);// set R-Bicep to home/rest position
servo4.write(180);//set L-Shoulder to home/rest position
}
if (res ==5) {
recognizer.say(“Sheild activated”);
digitalWrite(led3, HIGH); //Turns on Shield LED
}
if (res ==6) {
recognizer.say(“Pose initiated”);
//Test code
servo1.write(90);
for (servoPos = 0; servoPos <= 90; servoPos += 1) //Goes from 0 degrees to 90 degrees
servo2.write(servoPos); //We are controlling R-Shoulder
delay(8000);// waits 8sec for the servo to reach the position
for (servoPos = 30; servoPos <= 90; servoPos += 1) //Goes from 0 degrees to 90 degrees
servo3.write(servoPos); //We are controlling R-Bicep
delay(10000);// waits 10sec for the servo to reach the position
for (servoPos = 180; servoPos <= 90; servoPos += 1) //Goes from 180 degrees to 90 degrees
servo4.write(servoPos); //We are controlling L-Shoulder
delay(8000);// waits 8sec for the servo to reach the position
//End of test code
}
if (res ==7) {
recognizer.say(“Get Back! Get Back!”);
digitalWrite(led3, HIGH); //Turns on Shield LED
delay(5000);
digitalWrite(led3, LOW);
}
}

Use a flashing LED:
https://lighthouseleds.com/led-component-lighting/animated-leds-flashing-blinking/5mm-led-flashing-round-top.html

I don't want to use a flashing led. I have an 18 LED Board and I want it to strobe using code in Arduino. Does anyone know how to do that?

You will have to make extensive modifications to the code because you have to change the whole timing system to a non-blocking cooperative multitasking using millis(). Are you more of a copy and paste user, or can you really program?

Copy and paste. I'm learning (but i'm still a beginner) but I managed to program that code but it took a lot of trail and error and I combined and modified examples of codes that came with it.

So there's no way to loop that LED sequence you can't put a loop in a loop? Like a sub-loop?

classified123:
So there’s no way to loop that LED sequence you can’t put a loop in a loop? Like a sub-loop?

No, why do you say that?

Just wondering.