filmov
tv
Tutorial 04: Understanding Arduino Syntax: Arduino Course for Absolute Beginners (ReM)
Показать описание
🤩 FREE Arduino Crash Course 👇👇
*Click Below to Read About This Topic on Our Website*
We designed this circuit board for beginners!
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
We use Rev Captions for our subtitles
Arduino UNO R3:
Budget Arduino Kits:
Multimeter Options:
Helping Hands:
Soldering Stations:
AFFILIATES & REFERRALS
---------------------------------------------------
FOLLOW US ELSEWHERE
---------------------------------------------------
*Description:*
The coding language that Arduino uses is very much like C++ ("see plus plus"), which is a rather common language in the world of computing. As I have alluded to in previous lessons, the code you learn to write for your Arduino will be very similar to code you write in any other computer language - all the basic concepts remain the same - it's just a matter of learning a new dialect should you pursue other ventures.
The code you will be writing is called "human readable", that is, it will make sense to you (sometimes) and will be organized for a human to follow. Part of the job of the IDE is to take the human readable code and translate it into machine-readable code to be executed by the Arduino. This process is called compiling.
The process of compiling is seamless to the user. All you have to do is press a button. If you have some errors in your computer code, the compiler will display an error message at the bottom of the IDE and highlight the line of code that seems to be the issue. The error message is meant to help you identify what you might have done wrong - sometimes they are very explicit, like saying, "Hey - you forget a semi-colon", some times they are way out there.
Why would I be concerned with a semi colon you ask? A semi-colon is part of the Arduino languages syntax, the rules that govern how the code is written. It is sort of like grammar when you think of writing. Say for example we didn't use periods when we wrote - every one would have a heck of a time trying to figure out when sentences ended and started. Or if we didn't employ the comma, how would we convey a dramatic pause to the reader?
If you ever had an English teacher with an overactive red pen, the complier is 10 times worse. In fact - your programs WILL NOT compile without perfect syntax. This might drive you crazy at first because it is very natural to forget syntax, but as you program more you will to learn to be assiduous with coding grammar.
So lets get our hands dirty and introduce some sytax.
The semi-colon ;
A semi colon needs to follow every statement we write in Arduino. For example
int LEDpin = 9;
In this statement, I am assigning a value to an integer variable (we will cover this later), notice at the end, the semi-colon. This lets the compiler know that you have finished a chunk of code and are moving on to the next piece.
The double back slash for single line comments //
// When you type these all the text that follows on the same line will be greyed out
Comments are what you use to annotate your code. Good code is commented well. Comments are meant to inform you and anyone else who might stumble across your code, what the heck you were thinking when you wrote it. A good comment would be something like this...
//This is the pin on the Arduino that the LED is plugged into
int LEDpin = 9;
Now, in 3 months when I review this program, I know where to stick my LED.
Comments will be ignored by the compiler - so you can write whatever you like in them. If you have a lot you need to explain, you can also use a multi-line comment which looks like this...
/* The multi-line comment opens with a single backslash followed by an asterisk. Everything that follows is grayed out and will be ignored by the compiler, until you close the comment using first an asterisk and then a backslash like so */
Curly Braces { }
*Click Below to Read About This Topic on Our Website*
We designed this circuit board for beginners!
SHOP OUR FAVORITE STUFF! (affiliate links)
---------------------------------------------------
Get your Free Trial of Altium PCB design Software
We use Rev Captions for our subtitles
Arduino UNO R3:
Budget Arduino Kits:
Multimeter Options:
Helping Hands:
Soldering Stations:
AFFILIATES & REFERRALS
---------------------------------------------------
FOLLOW US ELSEWHERE
---------------------------------------------------
*Description:*
The coding language that Arduino uses is very much like C++ ("see plus plus"), which is a rather common language in the world of computing. As I have alluded to in previous lessons, the code you learn to write for your Arduino will be very similar to code you write in any other computer language - all the basic concepts remain the same - it's just a matter of learning a new dialect should you pursue other ventures.
The code you will be writing is called "human readable", that is, it will make sense to you (sometimes) and will be organized for a human to follow. Part of the job of the IDE is to take the human readable code and translate it into machine-readable code to be executed by the Arduino. This process is called compiling.
The process of compiling is seamless to the user. All you have to do is press a button. If you have some errors in your computer code, the compiler will display an error message at the bottom of the IDE and highlight the line of code that seems to be the issue. The error message is meant to help you identify what you might have done wrong - sometimes they are very explicit, like saying, "Hey - you forget a semi-colon", some times they are way out there.
Why would I be concerned with a semi colon you ask? A semi-colon is part of the Arduino languages syntax, the rules that govern how the code is written. It is sort of like grammar when you think of writing. Say for example we didn't use periods when we wrote - every one would have a heck of a time trying to figure out when sentences ended and started. Or if we didn't employ the comma, how would we convey a dramatic pause to the reader?
If you ever had an English teacher with an overactive red pen, the complier is 10 times worse. In fact - your programs WILL NOT compile without perfect syntax. This might drive you crazy at first because it is very natural to forget syntax, but as you program more you will to learn to be assiduous with coding grammar.
So lets get our hands dirty and introduce some sytax.
The semi-colon ;
A semi colon needs to follow every statement we write in Arduino. For example
int LEDpin = 9;
In this statement, I am assigning a value to an integer variable (we will cover this later), notice at the end, the semi-colon. This lets the compiler know that you have finished a chunk of code and are moving on to the next piece.
The double back slash for single line comments //
// When you type these all the text that follows on the same line will be greyed out
Comments are what you use to annotate your code. Good code is commented well. Comments are meant to inform you and anyone else who might stumble across your code, what the heck you were thinking when you wrote it. A good comment would be something like this...
//This is the pin on the Arduino that the LED is plugged into
int LEDpin = 9;
Now, in 3 months when I review this program, I know where to stick my LED.
Comments will be ignored by the compiler - so you can write whatever you like in them. If you have a lot you need to explain, you can also use a multi-line comment which looks like this...
/* The multi-line comment opens with a single backslash followed by an asterisk. Everything that follows is grayed out and will be ignored by the compiler, until you close the comment using first an asterisk and then a backslash like so */
Curly Braces { }
Комментарии