Tech Note 116 - Beginners guide to creating your own class and object

  Рет қаралды 24,641

G6EJD - David

G6EJD - David

Күн бұрын

Пікірлер: 89
@dineshvyas
@dineshvyas Жыл бұрын
Not a single book or any professional course explains it like this. This the best.
@km077
@km077 Жыл бұрын
As always: Dave comes by and everyone finally understands. Many thanks, Dave!
@uweri_3851
@uweri_3851 5 жыл бұрын
Thank you Dave for these tutorial. For me very helpful. Hope we get many more of these tutorials.
@queenidog1
@queenidog1 4 жыл бұрын
You did a good job. Easy to understand. Never knew what this OOP was before, now I do.
@7Trident3
@7Trident3 2 жыл бұрын
Thanks for the clear concise lesson. THIS is how teaching is done.
@bradywilson1177
@bradywilson1177 2 жыл бұрын
Thanks dude!!! I really appreciate you going slow with what you are explaining
@samdeur
@samdeur 3 жыл бұрын
Thank you very much... as a 46yr guy trying to wrap my head around classes and object i thought i would search how to create an Arduino class this is the first vid i have seen. After looking in to C# Object Oriented programming.. with the main goal of learning what OO is all about.. Thanks again sir.
@7Trident3
@7Trident3 2 жыл бұрын
59 and trying to understand machine learning, progress is being made! Keep exercising that brain.
@samdeur
@samdeur 2 жыл бұрын
@@7Trident3 That's awesome man.. i had a little break currently getting better from corona it's not to bad. Just a couple of weeks and then i'm going back taking C# by the horns and then to my destination C and C++.. Your so right exercising the brain is important. It's so funny that years ago people thought that at a certain age Neural plasticity declines. Science caught up and now we now the brain is like a muscle and training makes all the difference..
@davebeckham5429
@davebeckham5429 5 жыл бұрын
Very useful Dave. Looking forward for similar tech note. - Many thanks.
@thebaconbreadful
@thebaconbreadful 3 жыл бұрын
very basic and concise. Good tutorial to get a straight answer.
@asiw
@asiw 5 жыл бұрын
Thanks for a most useful and clear introduction to Classes.
@deangreenhough3479
@deangreenhough3479 5 жыл бұрын
Many thanks for reminding me of the basics and for the clear and concise tutorial. A pleasure to watch. 🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁥󠁮󠁧󠁿
@vikasverma8668
@vikasverma8668 3 жыл бұрын
Very nice explanation sir
@ryanowens100
@ryanowens100 4 жыл бұрын
may i ask why do you need to set up void Begin for the pinMode @2:16? i thought you can use pinMode without doing this? beginner here my apologies.
@G6EJD
@G6EJD 4 жыл бұрын
You can but this is a library that shows how you can set up a pin mode by a begin statement eg begin.sensor(22); could be replaced with pinmode(22,mode) in the main code. In a library it’s usual to have all required functions in the library itself.
@TheCrepinsek
@TheCrepinsek 5 жыл бұрын
I suggest to make video 2, where in class Led you use private: byte GPO, use constructor to set GPO, then update methods (remove GPO argument) declare for example Led ledIndicator(pin number); (creating object ledIndicator from class Led) ....in code ledIndicator.on(); ... Create more led objects...
@G6EJD
@G6EJD 5 жыл бұрын
Matej Črepinšek, it’s just an example, yes further improvements could be made, it’s more about the principles than refinement.
@TheOO23
@TheOO23 5 жыл бұрын
I totaly agree, some very important point are missing : having GPIO private, having just 1 method to set led status. Also you should warn coders that delay() is not suited for decoupling. Otherwise it is very clear, thx!
@courtneyvassell3712
@courtneyvassell3712 Жыл бұрын
We can't see what your doing, can you zoom in on what your doing, thanks
@kuillemaul4521
@kuillemaul4521 6 ай бұрын
The snoring in the background is the best
@G6EJD
@G6EJD 6 ай бұрын
That was Bertie the Jack Russel terrier 😀💤
@santorcuato
@santorcuato 5 жыл бұрын
Thanks Dave, clear and useful. Keep going!
@mksmurff
@mksmurff 5 жыл бұрын
Thanks for this. Genuinely found this all easy to understand
@omkarkhade4602
@omkarkhade4602 4 жыл бұрын
Very nice tutorial It helped me a lot.
@SebastianScholle
@SebastianScholle 3 жыл бұрын
Thanks for your great videos David. I'd like to suggest an improvement on the 'class'. That we store the GPIO pin as a member of the class, then we don't need to pass in the PIN on each function. - this helps reduce repetition of the 'LED_BUILTIN' variable and simplifies the code.
@G6EJD
@G6EJD 3 жыл бұрын
Agreed thanks.
@alejandroperez5368
@alejandroperez5368 3 жыл бұрын
But then you would lose the ability to choose which LED you want to operate...wouldn't you?
@G6EJD
@G6EJD 3 жыл бұрын
Yes I hadn’t thought of that aspect
@MeinLieberTurnschuh
@MeinLieberTurnschuh 2 жыл бұрын
@@alejandroperez5368 no. because either way you have to declare the pinmode for each gpio. So this class here is always only for one gpio. It might probably work because the pins are outputs on default. If you do it right you have to declare pinmode for every gpio. Just create an object for every LED
@dano4700
@dano4700 5 жыл бұрын
Cheers. I found that very clear.
@jedandecko5585
@jedandecko5585 5 жыл бұрын
Thanks, very nice and short explanation.
@dilshankasthuriarachchi4737
@dilshankasthuriarachchi4737 3 жыл бұрын
sir then we use if sentence and all the other data types and variables for this?
@G6EJD
@G6EJD 3 жыл бұрын
I do t understand your question. If you declare any variables within an if statement then they only exist within the if statement extents
@dilshankasthuriarachchi4737
@dilshankasthuriarachchi4737 3 жыл бұрын
@@G6EJD yeah i want you to know that can ve use any data type when writing a class can we?
@louiskatzclay
@louiskatzclay 2 жыл бұрын
Thanks David! I have sort of understood this for a while and have a project in need of simplifying. It is hard to find good easy to understand material on this. 73 de w0it.
@SymphonicSync
@SymphonicSync 3 жыл бұрын
Thank you so much. It was very clear, straight forward and useful.
@yousefabdallah-e7g
@yousefabdallah-e7g 11 ай бұрын
super underated and very helpful
@mikesfarmmikesfarm3977
@mikesfarmmikesfarm3977 2 жыл бұрын
thx much for this vid. I think this will help me from now on.
@skrame01
@skrame01 Жыл бұрын
Cqn you make the text smaller please?
@BLie2000
@BLie2000 3 жыл бұрын
good tutorial for the class and header file.
@Bahrami12
@Bahrami12 5 ай бұрын
Thanks a lot for this toturial❤
@JimK0QJC
@JimK0QJC 4 жыл бұрын
Very good example. I needed just that for a quick review. Please continue with your channel. W3IPO
@andrewkieran8942
@andrewkieran8942 5 жыл бұрын
Great content once again! I would welcome more programming techniques videos. For example, how would you write such a class, without using the 'delay' function which ties up the processor? I understand using millis but my programs without delays often become unwieldy. Perhaps you could explain how to use and manage state machines.
@michaelpadovani9566
@michaelpadovani9566 5 жыл бұрын
Great topic and awesome video once again Dave!
@G6EJD
@G6EJD 5 жыл бұрын
Is this because you have a lot of I/O going on and the delays help to visualise what is happening? In which case I can see how a state machine would help.
@andrewkieran8942
@andrewkieran8942 5 жыл бұрын
@@G6EJD I'm using ESP8266 modules and I understand why people recommend avoiding blocking code ,to keep the wi-fi running smoothly. I like how clearly and succinctly you explain things so I would be grateful if you'd delve into more programing techniques. I think state machines is one topic I'd like to better understand.
@Thinks-First
@Thinks-First 2 жыл бұрын
This is an excellent question. I'd like to know any and all techniques that allow the program to continue while allowing functions to be carried out at their own pace. Other than using outside hardware I have no idea how that is done.
@Thinks-First
@Thinks-First 2 жыл бұрын
0:30 Didn't you mean to say that "LED" was the OBJECT, not the CLASS ? The class is "LED_Controls". Great video though. It really helps me understand how Classes are created and used. You're excellent. I'll be following your work. THANK YOU !
@kosa2004
@kosa2004 5 жыл бұрын
A great tutorial again!! Learned a lot from you 🍻🍻🍻
@bertrandnadeau3254
@bertrandnadeau3254 4 жыл бұрын
Very clear explanation! I subscribe...
@alikeyhani9080
@alikeyhani9080 2 жыл бұрын
Thanks a lot man. It was wonderful!
@MaxGoddur
@MaxGoddur 5 жыл бұрын
What you just did is one of the few videos showing how to program using Arduino IDE. There is a need for more videos showing programming as you have done. I have searched for such videos using Arduino IDE and NodeMCU but have not found many. I currently am trying to incorporate Time into my sketch rather than using delays but NTP is rather large. Need to learn how to reference the time ino sketch I have copied and used as a stand-alone file referenced from my main ino sketch. Is this possible?
@G6EJD
@G6EJD 5 жыл бұрын
Yes, but it's a little tricky to format the time. Yes you could produce a .h file called 'my_time' or WHY and include that anytime. The trick is to put a small delay usually about 1-sec to allow time services to start, but you only need to do this one. Don't forget (libraries aside) any Arduino sketch will run on a Nodemcu. If you stuck for a time example I have one.
@MaxGoddur
@MaxGoddur 5 жыл бұрын
@@G6EJD How does one use time as in this example. String myTime=(timeClient.getFormattedTime()); if (myTime > 18:30) { Serial.println("It is alarm time"); } Not sure about all the in and outs for type data as in ; int, string etc.
@G6EJD
@G6EJD 5 жыл бұрын
@@MaxGoddur See this example: github.com/G6EJD/Examples/blob/master/ESP8266_Time_Services2.ino
@G6EJD
@G6EJD 5 жыл бұрын
Local time is a string so you need to do this if (localtime >”07:30”)
@MaxGoddur
@MaxGoddur 5 жыл бұрын
When I tried your example using local time I got the following error: NTPExample:42: error: stray '\342' in program if (localtime > �07:30�)
@MaxGoddur
@MaxGoddur 5 жыл бұрын
Will the code you show work if I upload to NodeMCU as written in your video?
@G6EJD
@G6EJD 5 жыл бұрын
Absolutely yes, I was merely using the UNO as a point of reference. In-fact I do all my testing on a NodeMCU.
@foodbygintea1822
@foodbygintea1822 5 жыл бұрын
Sir, thank you very much.. I'll pray for you
@jon_raymond
@jon_raymond 5 жыл бұрын
Thank you for explaining this!
@GarretsonIndustries
@GarretsonIndustries 5 ай бұрын
Why has no one mentioned auto format before
@G6EJD
@G6EJD 5 ай бұрын
It’s a little used compiler function that in 99.99% of choice it will get correct!
@justembedit
@justembedit Ай бұрын
thanks, that was really helpful
@BaronVonBiffo
@BaronVonBiffo 5 жыл бұрын
Succinct and very useful. Thank you.
@Johann75
@Johann75 2 жыл бұрын
Good & simple, but not the best example. The class looks more like just functions. I am also missing the private:, public: part explained...
@jameskuria1664
@jameskuria1664 3 жыл бұрын
Big up Dave
@rachidaliosinachi2065
@rachidaliosinachi2065 4 жыл бұрын
Honestly you’re excellent !
@Thinks-First
@Thinks-First 2 жыл бұрын
Very good.
@mrphysh
@mrphysh 5 жыл бұрын
"GPIO_pin" seems to fall out of the sky. This is a reference to pin 13, I know. This tells us that it is a "pneumonic", or reserved word, or something like that. I find no references to it. Can you confirm this. If I am an idiot, just tell me. I am cool with stuff like that. (good video)
@G6EJD
@G6EJD 5 жыл бұрын
Gpio_pin is a local variable defined at void begin(byte GPIO_pin)
@mrphysh
@mrphysh 5 жыл бұрын
@@G6EJD The definition I was missing is in the 'setup'. LED_BUILTIN I will keep going around and around with this. thanks
@G6EJD
@G6EJD 5 жыл бұрын
mrphysh some boards have this definition done not the UNO does and most ESP types do, if it’s not there you can define it with #define LED_BUILTIN 13 Or whatever pin you like or are using
@ralphsymmons4111
@ralphsymmons4111 4 жыл бұрын
Is that a dog snoring in the background? Many thanks for this concise guide.
@G6EJD
@G6EJD 4 жыл бұрын
Ralph Symmons, yes 😀 he insists on sleeping on my feet so I decided to carry on anyway, Bertie a 15-year old Jack Russell.
@surenbono6063
@surenbono6063 4 жыл бұрын
class Serial_Output { public: void B() { Serial.begin(9600); } void p(String n){ Serial.print(n); } void pl(String n){ Serial.println(n); } }; // Class Object Serial_Output S; void setup() { S.B(); } void loop() { S.p(" hello same line "); delay(1000); S.pl(" hello start next line"); delay(1000); } // With this class tuturial i simplified Serial.begin,print & println to S.B, S.p & S.pl...thnks
@MatSmithLondon
@MatSmithLondon 3 жыл бұрын
Is there a dog snoring in the background? Can hear it clearly with headphones :) Or maybe a human?!
@G6EJD
@G6EJD 3 жыл бұрын
Yes indeed our 16-year old Jack Russell - Bertie, always sat at my feet😀
@MatSmithLondon
@MatSmithLondon 3 жыл бұрын
@@G6EJD Awww. An old boy! We have a young cockerpoo, never sat still for more than 10 seconds, but still very loved! Thanks for the video... great introduction and very clear!
@Rayyarhs
@Rayyarhs 3 жыл бұрын
Thnx
@joymakerRC
@joymakerRC Жыл бұрын
love you thanks
@fooballers7883
@fooballers7883 Жыл бұрын
Nice tut....txs
Tech Note 117 - Creating an Arduino IDE Library (Part 1 of 4)
18:24
G6EJD - David
Рет қаралды 22 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Arduino OOP [40-Minute Crash Course]
42:12
Robotics Back-End
Рет қаралды 22 М.
Level Up Your Arduino Code: External Interrupts
18:55
SparkFun Electronics
Рет қаралды 174 М.
Tutorial: Object Oriented Programming with the Arduino
18:52
Make Course
Рет қаралды 55 М.
How to Organize Code
14:37
Programming Electronics Academy
Рет қаралды 65 М.
Level Up Your Arduino Code: Registers
21:09
SparkFun Electronics
Рет қаралды 187 М.
Functions vs Classes: When to Use Which and Why?
10:49
ArjanCodes
Рет қаралды 169 М.
#BB11 Create an Arduino Library😨 - A Real World Example (Easy)
25:54
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН