Using tabs to organize code with the Arduino IDE

preview_player
Показать описание
🤩 FREE Arduino Crash Course 👇👇

✅ PCB Assembly capabilities info:

***Want to learn more? Check out our courses!***

Arduino Sketch Build Process Website:

***Get the code, transcript, challenges, etc for this lesson on our website***

***We designed this circuit board for beginners!***

SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------

We use Rev Captions for our subtitles

Arduino UNO R3:

Budget Arduino Kits:

Multimeter Options:

Helping Hands:

Soldering Stations:

AFFILIATES & REFERRALS
---------------------------------------------------

FOLLOW US ELSEWHERE
---------------------------------------------------
________________________________
Did you know in the Arduino IDE that you can organize your code using different tabs? In this lesson, you’re gonna learn how to add these tabs, how they get organized in the Arduino sketch folder and how to use them in order to better organize your code. Stay tuned. Before we get started, if you wouldn’t mind subscribing to the channel, it really helps us bring you the best content. It doesn’t cost you anything but a click and it allows us to keep doing this. All right, so here we are in the Arduino IDE. I’ve got a program open. It’s called Tabbatha and I have got a sketch written out. So, let me just familiarize you with the sketch so you kind of get an idea what’s going on. So I’ve got some neopixels. Those are individually addressable LEDs. It’s like an individually addressable LED strip. You’ve probably seen ’em around. Really cool looking. And I’ve using this library called fastLED to control them. And I’ve got some variables here that set up the number of pins and which data pin I’m using and and a array to store the different LEDs that I’m in. Okay, and then I have some functions that do some different things. So one is setting them all the LEDs red. Then one sets ’em all blue, one sets ’em all green but it uses this little fadeall function in here that kind of makes it interesting. And I also have that function right here, fadeall. So I’ve got four functions and then below that I have my setup in my loop. So in setup, you know just start serial communication and then I’m just initializing some stuff for that fastLED library. Nothing crazy going on in setup. And then loop, all I’m doing is I’m calling these three functions: setRed, setBlue and setGreen. Okay, so what I wanna do is I wanna you know there’s a lot kind of, I don’t know, going on in here. Maybe I wanna like reduce the clutter in here and let’s say I wanna put each one of these functions in its own file, in its own tab. All right, so all of the files that you create in Arduino are gonna live in the Arduino Sketchbook folder. And you can figure out where your Sketchbook folder is by going to if you’re on a Mac, you’d go to Arduino Preferences or if you’re on a PC, I think it’s File Preferences. And the first thing they show is your Sketchbook location. So the location of my Sketchbook folder is under my name, my documents, and then in a folder Arduino. And then I have saved Tabbatha somewhere inside this folder. So I’m gonna go ahead and open that up. All right, so here is the folder Tabbatha and you’ll notice I’ve got a .eno
CONTINUED...

***About Us:***
This Arduino lesson was created by Programming Electronics Academy. We are an online education company that seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.

***We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.***
Рекомендации по теме
Комментарии
Автор

I chuckled to my self when you pulled out that 'TabbaDabba'. Thanks for helping us stay a little more organized.

slucas
Автор

You had me at FastLED LOL. And now I'm clear on tabs, prototypes and preprocessing. Another great tutorial, thank you!

burnermaster
Автор

I've been banging my head on the keyboard for a couple days trying to figure this out. I watched several videos that didn't help. THANK YOU!!! It's so much simpler than I thought.

PixelSchnitzel
Автор

I like it! This will make long sketches more manageable and easier to debug. I have an old non-Arduino program that I will rewrite as a sketch - it's 400 lines long. I'll use tabs.

keithable
Автор

I was looking for a video on how multiple sketches would work with each other inside a single folder and this really help

jeremiahradoc
Автор

A large sketch will require lots of scrolling. This is a neat solution and makes life easier. Thanks.

bernym
Автор

Thanks a lot for this! I have been coding Arduino for a while, and I didn't know about this! I guess this is what they call modular programming. It helps a lot to break things up in smaller, digestible pieces.

EFoxVN
Автор

Great and clear video! For my tabs I normally prefix them with 01, 02, 03 so I can sort them with the flow that I want instead of alphabetically.

jon_raymond
Автор

This is so easy to understand.
I can program Visual Basic but I'm a newbie to Arduino, and this allows me to modularise my code like VB.

waldo
Автор

So excited, I comment first.
I really hunger for this, didn't wrap my head around it first time, hopefully this time I'll due to my trust in your teachings. Because of your awesome teaching I ditched using delays despite it being a difficult habit to leave.

Greetings from Tanzania 🇹🇿
With "Royal Tour" :)

raymondmichael
Автор

Great info. I am a Subscriber now. I will label my tabs A=green b=red c=blue Thanks 👍

sandwon
Автор

Cool demonstration. This is a better approach to writing functions for your sketches. It will minimize scrolling to writing code blocks in one file and improve the writing process.

brucesmith
Автор

There was a question about if you could set up tabs, so that the functions could be used in other programs - and update in all the programs when the tab was updated - like a library (The comment disappeared when I was attempting to reply - my bad!).

This would be really pretty cool, but unfortunately it wouldn't work. You'd need to have copies of that .ino file in every sketch folder where you wanted to use it, and then every one of the files would need updated if you made changes. In that case, setting it up like a library would be the way to go.

programmingelectronics
Автор

Very helpful as i am just getting to splitting up larger files and searching the Arduino was not producing applicable results. Your video was clear and consise..

rcraig
Автор

EXTREMELY useful. Thank you. Yet to try it, but sure looking forward to making my code easier to read.

rtalbot
Автор

I'm new to programming in general, but I have read something about organizing our program. Help, I have questions :

1. since it works in alphabetically order, do we have to adjust the filename according to the program order (following which function come first in the source code) ?
2. what's the difference of calling function from this Tab method, and calling function from library/class (if I make a new file as a library) ?

Thank you very much for your clear and comprehensive tutorial, BTW

flickmew
Автор

Thanks for this tutorial, is kinda the concept of "MVC/MVVM" Controller structure for organizing code in iOS/Swift ...this is the way for any Object Oriented Programming ;) ...I like so much your teaching skills and I hope you would be the one starting teaching Swift and Arduino with the SwiftIO board architecture 🙏🏼

wilmercb
Автор

I have struggled with this for a couple of weeks:
A previously working sketch threw hundreds of errors when split into tabs.
My problem was that I appear to have fallen into the "rare cases" category, and had to manually add the prototypes up near my includes.

Subscribed.

digitalradiohacker
Автор

Very clear, thank you for your efforts.

When you named the first tab, I thought that you said "Your mama", I got seriously shocked for a moment 😂😂😂

NGeneral
Автор

Great video reminds me of the JSR instruction in RSLogix (jump to subroutine). Thank you for sharing.

Orcanian
visit shbcf.ru