Buenas noches.
Leyendo el tema
Donde se comenta, Como crear un proyecto Arduino de múltiples archivos cpp, y leyendo los enlaces a los que hace referencia de cómo dividir un programa, he entendido como hacerlo, y creo que no es tan difícil.
Aplicándolo a mi proyecto, y a posibles proyectos futuros, donde tenga que utilizar los mismos sensores.
Si yo me hago un programa donde solo haga funcionar un sensor, por ejemplo el giroscopio GY-MPU6050, cuando lo tenga que volver a utilizar el giroscopio, solo tengo que decirle al programa nuevo, que me incluya ese programa que ya hace trabajar al MPU6050, y no tendría que volver a escribir todas las líneas del código, que hacen trabajar al giroscopio.
Por ejemplo
Nombre del programa que yo he hecho para que funcione el giroscopio
MPU6050.cpp
Que está dentro de la carpeta
C:\mis_sensores\MPU60550.cpp
La orden seria
#Include “mis_sensores“ // carpeta donde están los códigos de los distintos sensores
Void set up
Init MPU6050 // inicia el giroscopio
Void loop
Int MPU6050.cpp (); // utiliza todas las ordenes del programa de trabajo de giroscopio
Y no tendría que escribir nada más para que el giroscopio funcionase.
Un saludo.
Good night.
Reading the topic
Where we comment, How to create an Arduino project of multiple cpp files, and reading the links to which it refers to how to split a program, I understood how to do it, and I think it is not that difficult.
Applying it to my project, and to possible future projects, where I have to use the same sensors.
If I do a program where I only run a sensor, for example the GY-MPU6050 gyroscope, when I have to use it again the gyroscope, I just have to tell the new program, to include that program that already makes the MPU6050 work, and I would not have to rewrite all the lines of the code, which make the gyroscope work.
For example
Name of the program I’ve done to make the gyroscope work
MPU6050.cpp
That’s inside the folder
C:\mis_sensores\MPU60550.cpp
The order would be
#Include “mis_sensores” // folder where the codes of the different sensors are
Void set up
Init MPU6050 // starts the gyroscope
Void loop
Int MPU6050.cpp (); // uses all the orders of the gyroscope work program
And I wouldn’t have to write anything else for the gyroscope to work.
Greetings.