Arduino - How to Split a Program Into Different Files

  Рет қаралды 51,328

Robotics Back-End

Robotics Back-End

Күн бұрын

Пікірлер: 49
@raymondmichael4987
@raymondmichael4987 Жыл бұрын
Finally, someone I can clearly understand the use of cpp and h files 😊 Thanks buddy
@RaniGiro
@RaniGiro Жыл бұрын
Great video, I think this video will help a lot of people who don't know how the scheme of c and c++ works, was very clear and concise!
@andrebalsa203
@andrebalsa203 2 жыл бұрын
Excellent! Very clear explanations, thank you very much. I am immediately going to use this knowledge for my current project (which has reached 2000 lines of code).
@vaishakhchavan8838
@vaishakhchavan8838 Жыл бұрын
Fantastic. Clear and perfect pitch. Appreciate the effort.
@inakilazcano2597
@inakilazcano2597 Ай бұрын
thanks very much mate, very useful, greetings from Puerto Madryn Argentina, from the robtics club of the 703 secondary school
@ET_AYY_LMAO
@ET_AYY_LMAO Жыл бұрын
What 99% of people coming here wants to know is, use double quotes, not < > when including files.
@lubenhristov1316
@lubenhristov1316 8 ай бұрын
Very useful video, showing in details the proper sequence of building structured Arduino project! Well done!
@sylcolinrakotonandrasana3694
@sylcolinrakotonandrasana3694 19 күн бұрын
that's an instructive video. I just have a question, how the cpp file is going to be called?
@rahul6306
@rahul6306 2 жыл бұрын
Hi, I have a few doubts. 1. f I am using the suppose 'X' library in Arduino which is used for let's assume filtering noise from the received signal. 2. so does that mean, that the library should consist of a .cpp and .h file? 3. .h file is like for declaring the variable? 4 .cpp is where the actual method(function) is created for filtering the noise? 5. and in the .ino file which acts as a receiver(created by me), from that I need to call the function which I want to use from my X library? thanks in advance.
@RoboticsBackEnd
@RoboticsBackEnd 2 жыл бұрын
Yes, you have the right understanding :)
@baghiat_salehat
@baghiat_salehat 2 жыл бұрын
Thank you. It was the best way to understand the header file.
@ELKopps11
@ELKopps11 Жыл бұрын
Now convert this into an LED class. Plans to do that? Or is there a video on that? I found it. Thanks!
@RoboticsBackEnd
@RoboticsBackEnd Жыл бұрын
Great to see both the question and the answer :)
@prachethire812
@prachethire812 5 ай бұрын
Doesn't works, I am using adafruit neopixel library, It always gives error "object not defined". I mean the created neopixel object. I tried defining the object in header file then too there is error.
@magnetiseur77
@magnetiseur77 Жыл бұрын
Lorsqu'on utilise ce genre de façon de faire (header) et que l'on appelle des fonctions dans ce header en passant des variables, pas de problèmes ? Les variables globales sont présentes aussi ? Merci
@RoboticsBackEnd
@RoboticsBackEnd Жыл бұрын
Pas de problème, une variable qu'on passe dans une fonction se retrouve en "variable locale" dans la fonction, que la fonction soit dans le même fichier ou pas. Pour les variables globales oui elles sont aussi présentes.
@galagatron5319
@galagatron5319 Жыл бұрын
Hi, I have 3 different sketches I need run at the same time. 1 sketch uses multiple servos, second is multiple leds, third is the play of a recorded track. Do I use 3 sketches for 1 arduino or do I use 3 arduinos and sketch individually. If the latter, i don't know how to connect 3 arduinos and make that happen. I'm trying to make a animintronic project and need all 3 sketches to start with a push of a button. Please help with short answers. Thank you.
@squilly1974
@squilly1974 Жыл бұрын
I had some code that was working fine. I then split it into the .cpp file, with the corresponding .h file. The issue I have is that now when I call the SPI functions in the new .cpp file I get errors about "unknow class type", errors in the actual SPI library that is part of the arduino ESP32 library. Any ideas why this is the case, or is it possible that the SPI library for the ESP32 is not able to be used this way? Any advice would be greately appreciated as I have spend hours on this and not got any further.
@RoboticsBackEnd
@RoboticsBackEnd Жыл бұрын
I would say to make sure you use the #include tags in every file where you need the library
@MayankMehraMusic
@MayankMehraMusic 2 жыл бұрын
I have a question. Why use .cpp, .h extensions ? Arduinos default .ino files directly imports functions. So we just call functions direcrly. Im just curious
@RoboticsBackEnd
@RoboticsBackEnd 2 жыл бұрын
This is a way to better organize your own code. Imagine that you have 2000 lines in your main .ino file, this is going to be horrible to manage :)
@MayankMehraMusic
@MayankMehraMusic 2 жыл бұрын
@@RoboticsBackEnd Okay. How about managing the code on multiple ino files. I'm just trying to understand the difference. Really appreciate your response.
@RoboticsBackEnd
@RoboticsBackEnd 2 жыл бұрын
@@MayankMehraMusic well technically I think you could create multiple ino files (make sure you don't have multiple setup() and loop() functions though). But I've never done it, never seen it, and I think it doesn't really make sense --> .h and .cpp files are working well and that's what you'd do in any other cpp project
@MayankMehraMusic
@MayankMehraMusic 2 жыл бұрын
@@RoboticsBackEnd Okay. Understood. Thanks alot for your valuable time.
@RobiBue
@RobiBue 2 жыл бұрын
@@MayankMehraMusic Sorry, I hate to be pedantic here, and I do understand the reasoning for the .h and .cpp files, but I fail to understand the reason of creating multiple prototypes for a single function like: void powerLED(byte pin, bool state); and then in the loop just write: powerLED(LED_PIN, HIGH); and powerLED(LED_PIN, LOW);
@Kotylion94
@Kotylion94 Жыл бұрын
5.28 shouldn't you be including cpp file here? I mean where is led_functions.cpp even mentioned once?
@RoboticsBackEnd
@RoboticsBackEnd Жыл бұрын
In your code you only include the .hpp file. Then how the .cpp file is used, that's the magic of compilation :) If you want to understand more, make some research on how C++ programs are compiled
@carlosviana694
@carlosviana694 Жыл бұрын
Três bien... Beaucoup m'aide...
@viktor_1939_
@viktor_1939_ 3 ай бұрын
do not use byte or similar thing? your code become unexportable to other platform.
@EngineeringToExcel
@EngineeringToExcel 2 жыл бұрын
Very good explanation.
@AtomTiger3460
@AtomTiger3460 2 жыл бұрын
Thanks a lot!
@Abdelrahman_Hosny
@Abdelrahman_Hosny Жыл бұрын
Very helpful Thank u
@KHALIFLA
@KHALIFLA 2 жыл бұрын
Very Helpful, Thanks you
@mehmetaltinsoy525
@mehmetaltinsoy525 6 ай бұрын
Thanks
@Venaber
@Venaber 2 жыл бұрын
So much thanks
@MonkeyMan9999
@MonkeyMan9999 3 жыл бұрын
Works good. One problem though. Was unable to use Serial.print from the .cpp file. This was true even after issuing Serial.begin(9600). Correct baud options and termination options were selected in terminal window. Still no output...
@ellisjacobs5011
@ellisjacobs5011 2 жыл бұрын
thank you.
@yjc5805
@yjc5805 3 жыл бұрын
thanks very much
@skoire7305
@skoire7305 3 жыл бұрын
Do you have to use .cpp , can it be .c ?
@RoboticsBackEnd
@RoboticsBackEnd 3 жыл бұрын
.c extension is for C language only, here as you use C++ (well, a subset of C++), you need the .cpp extension
@behzadabf
@behzadabf 2 жыл бұрын
perfeeect..!!!!
@yadwindersingh9494
@yadwindersingh9494 3 жыл бұрын
What is the benefit of this
@elko9404
@elko9404 2 жыл бұрын
When your projects get larger, this makes the main program file more readable
@realtuners707
@realtuners707 3 жыл бұрын
followed this exactly with a simple program of my own, and it fails repeatedly. I'm literally doing the exact same things, but it compiles just fine if I leave it all in one tab. Been trying to learn how to do this for months now.
@jugbang9387
@jugbang9387 2 жыл бұрын
Hi, I got the same pb and solved it by naming the tab led_functions.c and NOT .cpp and by replacing #include "led_functions.h" in the ino tab by #include led_functions.c. Hope that will help
@thevein8583
@thevein8583 3 жыл бұрын
Nice tutorial!! I got one question.. if i want upload all that split file... Can i upload one by one? Or it has another method to upload it?.. i got a split file in internet but i dont know how to upload that. Hope u can help me sir.. Done subscribe sir!! 👍
@muigaisimon4103
@muigaisimon4103 Жыл бұрын
how can i like the video twice?................hide your brain before they bewitch you sir😁😁😁lol
@champion6929
@champion6929 2 жыл бұрын
thanks a lot
Create an Arduino Library (Step by Step)
19:41
Robotics Back-End
Рет қаралды 47 М.
why do header files even exist?
10:53
Low Level
Рет қаралды 443 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
How to Organize Code
14:37
Programming Electronics Academy
Рет қаралды 65 М.
Using tabs to organize code with the Arduino IDE
12:18
Programming Electronics Academy
Рет қаралды 61 М.
PlatformIO: All you need to know in 10 Minutes!
10:56
J's e-shack
Рет қаралды 343 М.
Optimizing Arduino Code: no setup(), no loop() ⛔
9:27
Wokwi
Рет қаралды 212 М.
#BB11 Create an Arduino Library😨 - A Real World Example (Easy)
25:54
Understanding Arduino Interrupts | Hardware, Pin Change & Timer Interrupts
48:17
Arduino Uno to ATmega328 - Shrinking your Arduino Projects
37:17
DroneBot Workshop
Рет қаралды 803 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН