Controlling a moving shooting range, adding an LED


I teach and learn about the possibilities of Arduino.

I came up with the idea to build mobile targets for my son using foam cartridge guns.

Control by Arduino + relays + pneumatic solenoid valves + actuators.

So far I have created a code where for each channel I provide the parameters of delay time and duration of activation. The activation takes place after pressing the button on the cable. The action starts with a countdown, e.g. after 5 seconds (adjustable from 0 to 30 seconds in the code) after pressing the button.

I need to add a code with the LED diode blinking every second countdown and just before the action starts, it burns for example for 3 seconds.

Unfortunately, programming is black magic for me and that's why I am asking for help.

Here's the code:

//opoznienie i czas trwania w ms dla kanału 1
unsigned long opoznienie1 = 1400;
unsigned long czas1 = 50;

//opoznienie i czas trwania w ms dla kanału 2
unsigned long opoznienie2 = 1000;
unsigned long czas2 = 200;

//pin cyfrowy, pod który podłączony jest przycisk START
const int buttonPin = 2; 
int buttonState = 0;

unsigned long int last_millis;

void setup() 
  //tutaj wpisujemy instrukcje pinMode dla wszystkich kanałów
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);

  pinMode(buttonPin, INPUT);


void loop() 
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) 
    last_millis = millis();   


  if( millis() >= (last_millis + opoznienie1 + czas1))
    //tutaj wyłączamy urządzenia kanału 1
    digitalWrite(12, HIGH);
  else if( millis() >= (last_millis + opoznienie1))
    //tutaj uruchamiamy urządzenia dla kanału 1
    digitalWrite(12, LOW);

  if( millis() >= (last_millis + opoznienie2 + czas2))
    //tutaj wyłączamy urządzenia kanału 2
    digitalWrite(11, HIGH);
  else if( millis() >= (last_millis + opoznienie2))
    //tutaj uruchamiamy urządzenia dla kanału 2
    digitalWrite(11, LOW);

  //analogicznie tworzymy stałe const int dla pozostałych kanałów, oraz kopiujemy powyższe instrukcje warunkowe i zmieniamy zmienne


Thank you

There is much to learn. If this is discouraging you could post in 'gigs and collaborations' and prepare to compensate someone for writing the code.

In either case, as a starting point a drawing/schematic of your proposed hardware devices will be needed. Part numbers and ratings will help.

If you choose the learning route I suggest the first five demos in IDE -> file/examples/digital as a beginning.

And, as ever, there is: How to use this forum.

build mobile targets

What does mobile mean in this context?