Tutorial 04: Understanding Arduino Syntax: Arduino Course for Absolute Beginners (ReM)

preview_player
Показать описание
🤩 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 { }
Рекомендации по теме
Комментарии
Автор

i've watched many tutorials of all kinds (carpnetry, sports, astronomy you name it) and your style of talking and showing is probably the best i've seen. not repeating yourself unnecessarily, not wasting time in empty talk, not too slow, talking and showing the same thing, basically its just great. I really thank you for your work.

laius
Автор

Well done. You don't ramble, you speak clearly, use a good microphone and you're concise. Very logical and well organized. Refreshing to find a well made video like this.

spamcan
Автор

OMG Thank you so much for this. I'm in a engineering class and my teacher was horrible and i was so lost and still really wanted to learn coding and this video gives me hope! 

adventuresofavital
Автор

You are the FIRST person doing arduino tutorials that mentioned the PWM pins! Great instruction! Thanks for your efforts!

bogus_not_me
Автор

I HAVE A FRIGGEN PROJECT DUE ON MONDAY. THESE TUTORIALS ARE SO CLEAR, CONCISE AND EASY TO UNDERSTAND. I REALLY APPRECIATE YOUR GREAT WORK M8.

vnsn_ngyn
Автор

I like that you specified that comments are useful to future you first, and only mentioned other people later. I may be relatively new to this, hit even I know that you will not remember what everything is for weeks or months later lol

Hexsyn
Автор

I am now on video number 4, following your course through your site. Simply brilliant. I have always hated programming from my Turbo Pascal days and now look at it through new, enthusiastic eyes. Well done Sir! On the note of learning new things,  (and not meaning to be pedantic) I notice in your lesson you mention "...would just type WashDog, and whalla!, all the instructions would be carried out.". I presume you mean " voila ! "? ;-)

JustifyJustin
Автор

I've been trying to figure this stuff out on my own for days with internet research and a lot of trial and error. Your videos make it so clear and easy to follow, THANK YOU!!

sarahwesson
Автор

The best way of teaching anything to anyone is to divide topic into smallest bits, these tutorials does that well so far.
Before this I had no clue of what these simple commands does, and arduino site does bad job at explaining things, basically you need to analyze everything yourself...

joons
Автор

These tutorials are really helpful, I want to create a system that controls an homebrew in my shed. Onwards and upwards and Cheers

oldfartbrewery
Автор

Dont often Like videos but of all the videos I watched, these are the best series which explain EVERYTHING, even the little things that bug me which others skip over.

Bulgdoom
Автор

I am watching this videos in anticipation for my first Arduino! I bought one just today and am very excited for it to arrive. Thank you so much for sharing your knowledge.

TheyCallMeIVIonster
Автор

Starting a brand new Arduino course for grades 9-12 and I'm happy I came across your videos. You have a great way of explaining concepts and breaking everything down which I hope to emulate to my students. Keep up the great work!

BrandonPrentice
Автор

Glad to see that someone is explaining it deeply instead of just skipping through it :D

Geforsekiller
Автор

Thank you very, very, much. your valuable verbal discriptions helps a totally blind electronics fan. most of the other tutorials are completely visual, and I cannot get anything from them.  Thank you again.Samson

samsonperera
Автор

I love the way you take things step-by-step. I know nothing about arduino and have to learn about it for school, and with this I'm pretty sure I'll learn. Keep up the good work! :D You have definitely earned my subsribtion <3

erikvanhouten
Автор

Excellent! This video answers analog variables that are not answered on other videos. THANKS

jarrellestes
Автор

Thank you for that little bit of an explanation- I have watched a lot of videos about this subject- but it was usually too much too quickly. You have just explained it so that my 60 yr old brain could understand. Well done fella- much appreciated!!

thesewalkamongstus
Автор

Good Stuff! I tend to be a backward learner in that I will crack open something to play with, kinda figure out how to make it do 'this and that', and then want to know/learn why it did 'this and that'. Your tutorials here are spelling that all out for me. Thank You!

johnhart
Автор

Couldn't ask for a better tutorial, looking forward to finishing this series! Thank you so much!

alexsmith