Managing a multi-file project using the arduino-cli

A few months ago I discovered the arduino-cli and started using it for my projects because I really didn't like the arduino IDE and I wanted to improve my programming skills.
The problem is that I am now working on a bigger and more important project than usual and I need to manage it using multiple files.
The problem is that I have no idea how to use the arduino-cli to manage this using a makefile.

This is a simple test project with a main.ino

#include "blink.hpp"

void setup() {
    pinMode(13, OUTPUT);
}

void loop() {
    blink();
}

a header file (blink.hpp)

#pragma once

void blink();

a .cpp file (blink.cpp)

#include "blink.hpp"

void blink() {
    digitalWrite(13, HIGH);
    delay(100);
    digitalWrite(13, LOW);
    delay(200);
}

In case someone thinks I am trying to just make someone do my work and gets offended, I'm not doing that, I just need someone to help me get started

by cli, you presumably mean command line interface, or that you are executing commands directly instead of using the IDE to execute them.

i write all my code in a cygwin shell using vi. i write my code in a separate directory with a .ino matching the directory name. any addition files i create as .cpp file that include "Arduino.h" and which usually have a corresponding .h file.

but i use the IDE to compile, link, convert to .hex and download to the board. otherwise, i need to create a makefile to compile the separate source files and execute the other commands to build a .hex and download. i am proficient with makefiles and use them for all sorts of things besides build c code

a current project has the following file which i run on an esp32

Koala.ino  koala.h   menus.cpp   pcRead.h    utils.cpp  vars.h
file.cpp   menu.cpp  menus.h     server.cpp  utils.h
file.h     menu.h    pcRead.cpp  server.h    vars.cpp

thanks a lot, I didn't think about using the IDE for compiling and linking.
I've been writing makefiles for a week now but I don't quite know if I am doing it right, do you have any tips?

post you makefile

chapter 8 of The Unix Programming Environment on Program Development discusses the use of make (amoung other very interesting things)

You may want to check out Eclipse / Sloeber. It's a real, full-featured IDE and you don't have to mess around with vi, makefiles, and a CLI as if it was still the 1980s.

some of us use Linux (cygwin) as a development environment when working on large projects with project specific tools chains. how many editors are you going to learn to use over the course of your career

gfvalvo:
You may want to check out Eclipse / Sloeber. It's a real, full-featured IDE and you don't have to mess around with vi, makefiles, and a CLI as if it was still the 1980s.

This whole topic started because I want to avoid as much as possible using an IDE, I use VS code as a text editor

I am trying this code but it don't work. What is wrong? I tried a lot of options already .

1 int switchState = 0;

2void setup () {
  3 pinMode (3, OUTPUT);
  4 pinMode (4, OUTPUT);
  5 pinMode (5, OUTPUT);
  6 pinMode (2, OUTPUT);
  7
}


 8 void loop() {
  9   switchState = digitalRead(2);
  10 // this is a comment




  11 if (switchState == LOW) {
    12 // the button is not pressed










    13 digitalWrite(3, HIGH); // green LED
    14 digitalWrite(4, LOW); // red LED
    15 digitalWrite(5, LOW); // red LED
    16
  }



  17 else {  // the button is pressed
    18 digitalWrite (3, LOW);
    19 digitalWrite (4, HIGH);
    20 digitalWrite (5, HIGH);





    21 delay(250)  // wait for a quarter second
    22 // toggle the LEDs
    23 digitalWrite(4, HIGH);
    24 digitalWrite (5, LOW);
    25 delay(250); // wait for a quarter second


    26
  }
  27
} // go back to the beginning of the loop

Don't hijack a thread that has nothing to do with your problem. Please start a new topic. Also please read the sticky threads at the top of the forum, for instructions on how to use it.