🤩 FREE Arduino Crash Course 👇👇
bit.ly/get_Arduino_skills
**If you like this, I think you'll like the premium Arduino training we offer. Check it out here** bit.ly/3nSBPUs
Click Below to Read About This Topic on Our Website
www.programmingelectronics.co...
We designed this circuit board for beginners!
Kit-On-A-Shield: amzn.to/3lfWClU
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
www.altium.com/yt/programming...
We use Rev Captions for our subtitles
bit.ly/39trLeB
Arduino UNO R3:
Amazon: amzn.to/37eP4ra
Newegg: bit.ly/3fahas8
Budget Arduino Kits:
Amazon:amzn.to/3C0VqsH
Newegg:bit.ly/3j4tISX
Multimeter Options:
Amazon: amzn.to/3rRo3E0
Newegg: bit.ly/3rJoekA
Helping Hands:
Amazon: amzn.to/3C8IYXZ
Newegg: bit.ly/3fb03X1
Soldering Stations:
Amazon: amzn.to/2VawmP4
Newegg: bit.ly/3BZ6oio
AFFILIATES & REFERRALS
---------------------------------------------------
►Audible Plus Free trial: amzn.to/3j5IGrV
►Join Honey- Save Money bit.ly/3xmj7rH
►Download Glasswire for Free:bit.ly/3iv1fql
FOLLOW US ELSEWHERE
---------------------------------------------------
Facebook: / programmingelectronics...
Twitter: / progelecacademy
Website: www.programmingelectronics.com/
Description:
Lets have a discussion about a powerful and semi-confusing programming topic - variables.
A variable is like a bucket. You choose what types of stuff you want in the bucket and can change the contents as often as you like. When you declare a variable, you are telling the program two things, firstly - what types of things you plan to put in the bucket, and secondly, what the name of the bucket is so you can refer to it later.
If you tell the program you will be putting fluids in the bucket, than you can go all day filling it with beer, water, and iced tea - but the second you try to fill it with rocks, the compiler will call you out on your discrepancy. Only fluids go in a bucket declared for fluids. To declare a variable, you write the type of contents it will hold followed by the name:
fluid bucketVariable;
Notice in the above declaration statement that the word fluid is a different color - that is because Arduino knows variable data types - and they get a special color to reduce confusion and of course, because they are cool.
There are several types of variable data types you can declare. In this lesson we will discuss the integer data type.
You probably know that an integer is a whole number (no decimals). For Arduino an integer is a number from -32,768 to 32,767. If you try to put a number bigger than that into an integer variable, the value will roll over to the opposite side like a game of Pac Man. If you add 5 to 32,767, you would get -32,764. If you subtracted 5 from -32,768 you would get 32,763.
Integer is abbreviated int. Since an integer is an Arduino data type, it will change color to an orange.
int led; // an integer variable called led.
The name of the variable can be whatever you want with certain restrictions. There are also a couple good conventions to follow...
The variable name should be descriptive of its function, for example the ledPin variable could be the pin number that you put your LED into on your Arduino board.
By convention, most variables start lowercase.
Variable names cannot be the same as keyword names.
Now what if we want to put something in the bucket? Well we assign a value to the variable. When we first assign the value, it is called initialization, and we use the equal sign to do so. It looks like this.
int led; //first we declare the variable
led = 13; //now we initialize the variable
Or, we can initialize and declare a variable at the same time...
int led = 13; //declare and initialize a variable with a single statement
Now if you are going to initialize a variable (that is, assign it a value to hold) before the setup() function, then you must do it all in one line like this:
int led = 13;
void setup(){
}
Or you can do it like this:
int led;
void setup(){
led = 13;
}
Well, that's all we will talk about variables for now. I hope you have a basic idea of how they are declared and initialized.
Read More...
opensourcehardwaregroup.com/t...
About Us:
This Arduino tutorial was created by Open Source Hardware Group. We are an education company who seek to help people learn about electronics and programming through the ubiquitous Arduino development board.
Негізгі бет Ғылым және технология Tutorial 05: Understanding Variables: Arduino Course for Absolute Beginners (ReM)
Пікірлер: 190