Finally, someone I can clearly understand the use of cpp and h files 😊 Thanks buddy
@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!
@andrebalsa2032 жыл бұрын
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 Жыл бұрын
Fantastic. Clear and perfect pitch. Appreciate the effort.
@inakilazcano2597Ай бұрын
thanks very much mate, very useful, greetings from Puerto Madryn Argentina, from the robtics club of the 703 secondary school
@ET_AYY_LMAO Жыл бұрын
What 99% of people coming here wants to know is, use double quotes, not < > when including files.
@lubenhristov13168 ай бұрын
Very useful video, showing in details the proper sequence of building structured Arduino project! Well done!
@sylcolinrakotonandrasana369419 күн бұрын
that's an instructive video. I just have a question, how the cpp file is going to be called?
@rahul63062 жыл бұрын
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.
@RoboticsBackEnd2 жыл бұрын
Yes, you have the right understanding :)
@baghiat_salehat2 жыл бұрын
Thank you. It was the best way to understand the header file.
@ELKopps11 Жыл бұрын
Now convert this into an LED class. Plans to do that? Or is there a video on that? I found it. Thanks!
@RoboticsBackEnd Жыл бұрын
Great to see both the question and the answer :)
@prachethire8125 ай бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
I would say to make sure you use the #include tags in every file where you need the library
@MayankMehraMusic2 жыл бұрын
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
@RoboticsBackEnd2 жыл бұрын
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 :)
@MayankMehraMusic2 жыл бұрын
@@RoboticsBackEnd Okay. How about managing the code on multiple ino files. I'm just trying to understand the difference. Really appreciate your response.
@RoboticsBackEnd2 жыл бұрын
@@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
@MayankMehraMusic2 жыл бұрын
@@RoboticsBackEnd Okay. Understood. Thanks alot for your valuable time.
@RobiBue2 жыл бұрын
@@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 Жыл бұрын
5.28 shouldn't you be including cpp file here? I mean where is led_functions.cpp even mentioned once?
@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 Жыл бұрын
Três bien... Beaucoup m'aide...
@viktor_1939_3 ай бұрын
do not use byte or similar thing? your code become unexportable to other platform.
@EngineeringToExcel2 жыл бұрын
Very good explanation.
@AtomTiger34602 жыл бұрын
Thanks a lot!
@Abdelrahman_Hosny Жыл бұрын
Very helpful Thank u
@KHALIFLA2 жыл бұрын
Very Helpful, Thanks you
@mehmetaltinsoy5256 ай бұрын
Thanks
@Venaber2 жыл бұрын
So much thanks
@MonkeyMan99993 жыл бұрын
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...
@ellisjacobs50112 жыл бұрын
thank you.
@yjc58053 жыл бұрын
thanks very much
@skoire73053 жыл бұрын
Do you have to use .cpp , can it be .c ?
@RoboticsBackEnd3 жыл бұрын
.c extension is for C language only, here as you use C++ (well, a subset of C++), you need the .cpp extension
@behzadabf2 жыл бұрын
perfeeect..!!!!
@yadwindersingh94943 жыл бұрын
What is the benefit of this
@elko94042 жыл бұрын
When your projects get larger, this makes the main program file more readable
@realtuners7073 жыл бұрын
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.
@jugbang93872 жыл бұрын
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
@thevein85833 жыл бұрын
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 Жыл бұрын
how can i like the video twice?................hide your brain before they bewitch you sir😁😁😁lol