7 Arduino Tips for New Programmers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
are you a new programmer getting started with arduino i've got seven tips here to get you on the fast track let's jump right in [Music] subscribe to our youtube channel to get more videos like this tip one algorithm first now this is not just arduino specific this is any programming language specific it's like when you're a new programmer you just want to jump in and start typing code i get it because i love writing code too but the best place to start your new program is actually with a pencil and paper what you can do is write down what your program's going to do step by step when you're doing this you're essentially writing the algorithm once you know what it is you need your code to do then you can actually go and implement that algorithm into your arduino code now you might be like oh my gosh this is such an easy sketch to write i don't need to waste my time writing out an algorithm and that might be true with a simple sketch that you have in mind maybe you don't have to but you're going to be amazed at what pops out if you take the time to write your algorithm first tip 2 know these arduino input output and serial functions cold now i'm not into rote memorization mostly because i can't remember anything but it is important to be aware of these functions so the digital input output functions are for controlling the digital pins and you'd use be using functions digital read digital write and pin mode so this would be for controlling things like leds and perhaps reading inputs from say a button press now the analog functions you should know are analog read and analog write and those things would be for like reading in from some type of sensor like maybe a temperature sensor reading from a potentiometer and analog right let's say you want to fade in led or adjust the speed of a motor or something like that and then the serial functions you want to be aware of are serial begin serial print and serial print line and what those allow you to do is print out information at key points in your sketch so you can kind of understand the how the flow is working kind of debug along the way as you're programming the best place to learn more about these is on the arduino reference page we'll link to that in the description we also have videos on just about every one of these functions so check out our youtube channel or our website for more information on that i don't know about you but when i find a useful piece of code online i usually bookmark it in my browser so i can find it again but the problem is finding it again in my bookmarks is pretty hit or miss i mean i've got a ton of bookmarks and i try to categorize them smart you know usually like i'm doing something else though like solving a coding problem and i just don't really have the time to categorize them like i should i actually have a little fairy tale that plays in my brain every time i save a little code bookmark it goes something like this someday i'll organize all my coding bookmarks i have a feeling though that day will never actually arrive what i really need is some kind of auto magic tagging organizer app that can save all these different pieces of code with the click of a hotkey and then just allow me to find them when i actually need them so that's why i started using pieces it's an application built by developers for developers that helps you keep track of all your code snippets without screwing up your workflow using pieces is insanely simple on the web you just highlight any code or text and then right click or use a keyboard shortcut to save to pieces or just hover over any code and click the pieces save button it literally takes less than a second what's really cool is not only does it save the code but it saves the url of where you got the code so you've got like context to go with it it auto detects the type of language and it categorizes it for you that's pretty cool but where it gets really nice is being able to quickly find that code inside your ide of choice i use vs code quite a bit and the pieces extension allows me to save and insert code snippets right inside the ide so instead of searching through some old project for that piece of code i know i use all the time i just save it to pieces and then auto insert it they even have an auto save feature that automatically saves code snippets that you frequently type getting started with pieces is simple just go to pieces.app to download for your pc or mac and then install the plugins wherever you find yourself coding or looking for code that is pieces.app to download this free software tip three find an example sketch so one of the great things about arduino is that it's got a huge community and tons of people write example sketches often if you need to do something you can find an example sketch that's going to kind of be along the lines of what you need to do one great place to find example code is right inside the arduino ide all you do is go to file and then examples here you can find examples for all the basic arduino functions and many of your pre-installed arduino libraries tip four incremental design always so i would highly recommend doing one small thing at a time and that goes for code and for circuits so you don't want to like wire up two circuits and then test that they both work you want to wire up one circuit test that that one circuit works then add a second circuit and test it that works too maybe you're building like a wireless temperature sensor that's cool so first use a simple example sketch to test that you can actually read the temperature probe all by itself no wi-fi then in a separate sketch totally unrelated see if you can establish the simplest wi-fi connection possible make sure that can work but don't try to do both of those all at the same time if you begin to have issues it's hard to pinpoint the specific area but if you do it one small piece at a time get that one small piece working when you try to do it all at once it makes it far more difficult to identify an issue should one crop up or should i say when the issues start to crop up tip 5 verify verify verify so how can you be a better coder well if you find your errors faster what's a quick way to find an error well it's to test every line of code you write all right so my guess is we're all humans here i mean maybe you're a cyborg i don't know but humans make errors regardless of how long you're going to code you're always going to make errors in your code it doesn't matter maybe you'll make less errors as you get more experienced or maybe you'll make more complicated errors as you get more experience but one way to code better is to find your errors faster well how do you find your errors faster well what you can do is verify your sketches frequently so anytime you write a line of code you can verify it and see if any errors crop up if you verify frequently you can catch your errors more quickly and end up with better code tip six naming is more important than you think programming requires naming stuff anytime you're writing a function or you're creating a variable you got to give it a name and i would say anytime you're going to name something pretend you're naming a baby why because when you name a baby you're probably going to put some mental effort into it it's important to you i mean it's your baby for programming we want names to convey useful information for example what does the variable name tsbt mean to anybody wouldn't temp sensor bottom tank be a whole lot more descriptive the second one sure gives you a whole lot more detail and somebody else reading your code might not accidentally think it means tank sensor bottom threshold now a great source for thinking about naming is in a book called clean code by robert c martin highly recommend you check it out fantastic book tip 7 use functions if you are brand new to programming and arduino you might not be writing your own functions yet and all your code is right inside like the main loop of arduino but writing functions can make your code more concise easier to read and simpler update so what kind of code should you turn into functions well look for sections of your code that you're repeating often in your sketch if you find yourself writing the same piece of code over and over again that might be a good indication that you could turn that piece of code into a function so if you'd like to get these seven tips plus three more in an easy pdf download check out our website at programmingelectronics.com forward slash 10 tips that's programmingelectronics.com forward slash 10 tips well hey thanks so much for watching if you've got a tip that you think would be great for arduino programmers to know please leave it in the comments we'd love to hear it share it with your fellow programmers also if you're interested in learning more about this arduino programming stuff make sure to check out the training program at our website programmingelectronics.com huge shout out to our sponsor pieces for supporting this video you can check out their software in the link below or just go to pieces.app that's pieces.app to check out their super useful snippet software that i'm really enjoying using and i think you'd find handy too thanks a ton would love if you subscribe to the channel like the video all that great stuff take it easy bye [Music] you
Info
Channel: Programming Electronics Academy
Views: 45,846
Rating: undefined out of 5
Keywords: Arduino, Arduino(Brand), Arduino Tutorial, Arduino Lesson, Open Source Hardware Group, Learning Arduino, Microcontrollers, Electronics, Arduino IDE, Arduino Sketch, Computer programming, C++, Programming Electronics Academy, learn to code, computer programming language, arduino projects for beginners, Arduino for, arduino for beginners, arduino for beginners tutorial, arduino uno, programming tips, arduino tutorial for beginners, learn to code for free, arduino uno projects
Id: Wblb387Kir0
Channel Id: undefined
Length: 9min 40sec (580 seconds)
Published: Fri Feb 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.