Arduino Tutorial 1: Setting Up and Programming the Arduino for Absolute Beginners

Paul McWhorter
31 May 201923:50

Summary

TLDRIn this video, Polemic Order from Top Tech Boy Comm introduces a new series of Arduino tutorials, highlighting updates in both hardware and software since his previous lessons. He guides viewers through setting up the Arduino IDE, selecting the correct board and port, and writing basic programs to control an on-board LED, including making it blink with different on/off durations. The tutorial is designed for beginners, aiming to teach microcontroller programming from scratch, and ends with an assignment to experiment with LED blink rates.

Takeaways

  • 😀 The video is an introduction to a new series of Arduino tutorials by Polemic Order from Top Tech Boy Comm.
  • 🔧 There have been significant changes in Arduino hardware and software since the previous tutorial series, necessitating an update to the lessons.
  • 💻 The presenter has improved their studio and production quality, enhancing the learning experience for viewers.
  • ☕ The presenter humorously notes a change in coffee-drinking habits from hot to iced coffee as part of the new series.
  • 📝 The tutorial series is designed to start from scratch, teaching absolute beginners how to program a microcontroller.
  • 🛠️ A 'super starter kit' from E Lego is recommended, costing $35 and including an Arduino along with numerous components for projects.
  • 🔗 The kit provides enough components for hundreds of projects, offering great value for money.
  • 🔍 The tutorial includes a step-by-step guide on how to download and install the latest Arduino software.
  • 🔌 The presenter demonstrates how to connect the Arduino to a PC using a USB cable and verify the connection through the Arduino IDE.
  • 💡 The first program taught is to light up an LED on the Arduino board using the built-in pin 13, without the need for additional wiring.
  • 🔄 The subsequent programs show how to turn the LED off and make it blink, introducing the concepts of digital output and delay functions.

Q & A

  • What is the main purpose of the video?

    -The main purpose of the video is to introduce a new series of Arduino tutorials, highlighting the changes in hardware, software, and production quality since the last series, and to guide viewers through setting up their Arduino environment and writing basic programs.

  • What has changed since the last series of Arduino lessons?

    -The hardware has evolved with more sensors and components, the software has been updated, the production quality of the tutorial videos has improved, and the presenter will be drinking iced coffee instead of hot coffee during the lessons.

  • What is the first step for a beginner to start with Arduino as mentioned in the video?

    -The first step is to order an Arduino kit, specifically the super starter kit by E Lego, which includes an Arduino and a variety of components needed for numerous projects.

  • How much does the Arduino super starter kit cost?

    -The Arduino super starter kit costs $35.

  • What software is required to program the Arduino and where can it be downloaded from?

    -The required software is the Arduino IDE, which can be downloaded from the official Arduino website (arduino.cc) under the 'Software' section.

  • What is the name of the example program provided in the video for beginners to start with?

    -The example program provided is called 'Bare Minimum', which is a basic template for starting an Arduino program.

  • What are the two main components of every Arduino program?

    -The two main components of every Arduino program are the 'void setup()' function, which runs once to set up the Arduino, and the 'void loop()' function, which contains the code that runs repeatedly.

  • How does the video guide viewers to verify that their Arduino is connected to their PC?

    -The video guides viewers to check the 'Tools' and 'Port' sections in the Arduino IDE to ensure that the correct COM port with the Arduino connected is selected and recognized by the PC.

  • What is the purpose of the 'pinMode' function in Arduino programming?

    -The 'pinMode' function is used to set the mode of a digital pin, specifying whether it should be used as an input or an output.

  • How does the video demonstrate turning an LED on and off using the Arduino?

    -The video demonstrates this by using the 'digitalWrite' function, setting pin 13 to 'HIGH' to turn the LED on and to 'LOW' to turn it off.

  • What is the role of the 'delay' function in the Arduino program shown in the video?

    -The 'delay' function is used to pause the program for a specified number of milliseconds, allowing for time-based actions such as blinking an LED at a perceivable rate.

  • What assignments does the presenter give to the viewers at the end of the video?

    -The presenter assigns the viewers to write a program that makes an LED blink very fast, challenging them to find the threshold at which the blinking is no longer perceivable to the human eye.

Outlines

00:00

😀 Introduction to New Arduino Tutorial Series

The speaker, Polemic Order from Top Tech Boy Comm, introduces a new series of Arduino tutorials. He mentions that his previous series was popular, but a refresh is necessary due to changes in hardware, software, and an improved studio setup. The speaker emphasizes that the new series will be more beginner-friendly, teaching even those with no prior knowledge how to program a microcontroller. The video promises that viewers will write their first four programs by the end of the session. A starter kit from E Lego is recommended for the tutorials, which is affordable and includes a variety of components for numerous projects.

05:00

🔧 Setting Up the Arduino Environment

The tutorial proceeds with instructions on how to set up the Arduino environment. The speaker guides viewers on downloading and installing the latest Arduino software from the official website. He details the process of selecting the correct installer for Windows and emphasizes the importance of agreeing to the Terms of Service during installation. The video shows the software being installed and ready for use, with a focus on the ease of access from the taskbar for convenience.

10:02

🔌 Connecting Arduino Hardware and Writing Basic Code

After installing the software, the speaker demonstrates how to connect the Arduino hardware to the computer using a USB cable. He explains the significance of hearing a 'happy little noise' indicating that the computer recognizes the Arduino. The video then covers the basics of writing an Arduino program, starting with the 'Bare Minimum' example which includes the essential 'void setup' and 'void loop' functions. The speaker clarifies the purpose of each function and how they are structured within an Arduino program.

15:02

💡 Controlling an LED with Arduino

The speaker walks through the process of writing a simple program to control an LED light on the Arduino board. He explains how to set the pin mode and use the 'digitalWrite' function to turn the LED on and off. The tutorial includes a practical demonstration of compiling and uploading the code to the Arduino, resulting in the LED lighting up as expected. The speaker also discusses the importance of correct syntax and capitalization in Arduino programming.

20:04

👀 Exploring Blink Rates with Arduino

Building on the previous lesson, the speaker introduces the 'delay' function, allowing the LED to blink at a perceivable rate. He explains how to adjust the delay time to control the blink frequency and demonstrates different blink patterns by modifying the delay duration. The tutorial explores the concept of duty cycle, showing how to make the LED stay on for a shorter or longer period within the blink cycle. The speaker encourages viewers to experiment with different blink rates and share their findings in the comments.

📚 Assignments and Conclusion

To conclude the tutorial, the speaker assigns the viewers a task to write a program that makes the LED blink at an extremely fast rate, challenging them to find the threshold at which the blink becomes imperceptible to the human eye. He invites viewers to share their results and experiences in the comments section. The speaker also encourages viewers to like, subscribe, and share the video, and to follow along with the tutorial series for more Arduino programming lessons.

Mindmap

Keywords

💡Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is widely used for creating various projects involving electronics. In the video, Arduino serves as the central hardware for the tutorial series, with the presenter using it to demonstrate programming and electronics concepts.

💡Integrated Development Environment (IDE)

An Integrated Development Environment is a software application that provides comprehensive facilities to computer programmers for software development. In the context of the video, the Arduino IDE is used for writing, compiling, and uploading code to the Arduino board, highlighting the importance of an IDE in the development process.

💡Microcontroller

A microcontroller is a small computer on a single integrated circuit containing a processor, memory, and input/output peripherals. In the video, the presenter aims to teach viewers to program a microcontroller using the Arduino platform, which is a foundational skill in electronics and programming.

💡Sensors

Sensors are devices that convert physical or chemical information into electrical signals. In the script, the presenter mentions that new hardware advancements include a variety of sensors, which can be used with the Arduino for detecting different types of environmental data.

💡Actuators

Actuators are components that move or control a mechanism or system. The video script discusses the inclusion of actuators in the Arduino starter kit, indicating that they can be controlled by the Arduino to perform various actions in a project.

💡Blink

In the context of the video, 'blink' refers to the action of an LED turning on and off rapidly to create a flashing effect. The presenter uses the LED blink as a simple yet illustrative example to teach beginners how to control hardware with the Arduino.

💡Delay

In programming, a delay function is used to pause the execution of the program for a specified amount of time. The video demonstrates the use of the delay function in the Arduino code to control the blinking speed of an LED, showing its importance in timing operations.

💡Duty Cycle

The duty cycle is the ratio of the duration of the output signal in a fixed period of time. In the video, the presenter adjusts the duty cycle of the LED blinking by changing the on and off times, demonstrating how to control the brightness perception of the LED.

💡Digital Pin

Digital pins on an Arduino board are used to send or receive digital signals. The script mentions pin 13, which is connected to an LED on the board, and is used to demonstrate basic digital output by turning the LED on and off.

💡Program

In the context of the video, a program refers to a sequence of instructions written in the Arduino programming language to control the board's functions. The presenter guides viewers through writing their first few programs to interact with the Arduino hardware.

💡Assignment

Assignments in the video are tasks given by the presenter for viewers to practice and apply what they have learned. For example, the presenter asks viewers to write a program that makes an LED blink at different speeds, encouraging hands-on learning and experimentation.

Highlights

Introduction of new and improved Arduino tutorials by Polemic Order from Top Tech Boy Comm.

Necessity to update Arduino lessons due to changes in hardware, software, and studio production quality.

The presenter's improved studio and commitment to higher production quality in the new tutorial series.

The presenter's switch from hot to iced coffee as a fun, memorable change in the new tutorial series.

The goal of teaching absolute beginners to program a microcontroller from scratch.

Introduction of the 'super starter kit' by E Lego as the hardware to be used in the tutorials.

The kit's affordability and comprehensive components suitable for numerous projects.

Instructions on how to order the Arduino kit and prepare for the tutorial series.

Step-by-step guide on installing the Arduino software on Windows 10.

Explanation of how to download and install the latest version of the Arduino IDE.

Demonstration of verifying Arduino connection via the IDE's port selection.

Overview of the 'Bare Minimum' program structure in the Arduino IDE.

Explanation of the 'void setup' and 'void loop' functions in every Arduino program.

Tutorial on writing the first program to turn an LED on using pin 13.

Guide on using 'pinMode' and 'digitalWrite' to control the LED state.

Writing a second program to turn the LED off and understanding digital logic.

Creating a third program to make the LED blink with the introduction of 'delay'.

Experimenting with different blink rates to perceive the threshold of visibility.

Assignment for viewers to write a program for fast blinking LED and share results.

Encouragement for viewers to subscribe, share, and comment on the tutorial.

Transcripts

play00:00

hello guys this is polemic order from

play00:02

top tech boy comm and I am here today

play00:05

with the all-new the improved Arduino

play00:08

tutorials now those of you who are

play00:10

familiar with my channel know that I

play00:11

have a very very popular series of

play00:15

lessons on the Arduino that I made

play00:17

several years ago

play00:18

and a lot of people have watched him a

play00:20

lot of people have really loved them but

play00:22

it is time to redo those videos because

play00:24

a lot has changed the first thing that

play00:26

has changed a lot of the hardware is

play00:28

changed there's more sensors there's all

play00:30

types of more things that we can do with

play00:32

the Arduino due to the new hardware

play00:34

second thing is there's been some

play00:36

changes in the software and so we really

play00:39

need to redo things with the newer in a

play00:41

integrated development environment the

play00:43

third thing is that I have an improved

play00:46

studio and so some of the production

play00:48

quality was pretty low

play00:49

I think the content in the first series

play00:51

of lessons was really good but the

play00:53

production quality was pretty low and so

play00:55

I've got better production quality right

play00:57

now so it's really time to meet remake

play01:00

the videos but probably the most

play01:01

important changes is that if you

play01:03

remember in the first set of videos I

play01:05

would drink hot coffee from this cup for

play01:09

this series of lessons I will be

play01:11

drinking iced coffee from this big mug

play01:15

so I need you to go pour yourself a nice

play01:19

big mug of iced coffee and get ready to

play01:23

follow along if you're new to Arduino

play01:25

before we get to the end of this video

play01:27

you're going to have not only written

play01:29

your first program you're gonna have

play01:31

written your first four programs and

play01:33

then I'm going to give you some simple

play01:34

assignments of things to do on your own

play01:36

based on what you learn today but today

play01:39

you will get in and you will write your

play01:42

first set of programs now if your if you

play01:44

were here before the first 4 or 5

play01:47

lessons are going to be repeat you can

play01:48

just kind of skip to the more advanced

play01:50

things but I want to start all the way

play01:52

back at the beginning so we can take a

play01:54

person off the street who knows

play01:56

absolutely nothing and we can teach them

play01:58

to program a microcontroller step 1 you

play02:01

need to get your hardware this series of

play02:04

lessons I will be using this super

play02:06

starter kit you know our three project

play02:09

by E Lego available at the convenient

play02:12

link below

play02:13

in the description hook a brother up get

play02:16

your kid from there this kit cost $35 it

play02:18

includes an Arduino and then just a

play02:21

boatload of components this kit is going

play02:25

to keep us busy for a long time because

play02:27

it's got sensors it's got actuators it's

play02:29

got circular elements it's got

play02:31

everything you need to do hundreds of

play02:34

projects so bargain at $35 step one

play02:37

order your Arduino kit if you already

play02:41

have an Arduino you can go ahead and

play02:43

start playing along right off the bat

play02:46

okay so get your kit ordered step number

play02:50

two we have to install the software and

play02:53

that's that's what I'm going to show you

play02:54

how to do today and the simplest thing

play02:57

is we can go to a google browser I can

play03:01

make myself smaller to get out of your

play03:03

way and then what we just want to search

play03:06

on is arduino AR DUI in o download ok

play03:12

boom first result is the website WWE no

play03:17

CC / ian / main / software we will go

play03:21

there and this is where we download the

play03:24

most excellent and free software I am

play03:27

running on Windows 10 and I will

play03:29

download the latest version of the

play03:31

software as of the time I'm making this

play03:33

video the latest version is arduino one

play03:35

point 8.9 you don't have to download

play03:38

this exact copy this exact version just

play03:42

download whenever you do whatever the

play03:44

latest version is so whatever it says

play03:45

here that's fine there'll be little

play03:47

tweaks but what I'm showing you here

play03:49

should work for a long long long time

play03:51

now I'm on Windows 10 so I'm gonna click

play03:54

on this link which says Windows

play03:55

installer for Windows XP and up if

play03:58

you're on Windows 10 this is what you

play04:01

would click or if you're on Windows XP

play04:03

or higher this is where you will click

play04:04

so we will click there what they are

play04:07

asking you to do is hook a brother up

play04:09

and make a donation I have helped out

play04:12

already and so I'm going to just say

play04:14

just download so I click and then down

play04:17

here if you're in Chrome in the lower

play04:19

left you can see the little exe

play04:21

installer is downloading

play04:24

happening pretty quickly so we will just

play04:26

wait for it it has downloaded so now we

play04:31

just click on that downloaded file if

play04:34

you're not on Google Chrome then you've

play04:36

got to kind of go hunt around and find

play04:38

where that file was downloaded to but on

play04:40

Chrome we just click on it it is asking

play04:46

me are you sure you want to let Arduino

play04:48

change your computer well yes I will

play04:51

click yes and now it's saying do I agree

play04:54

with the Terms of Service yes I agree

play04:56

I'm going to do a pretty standard

play04:58

installation so I'll just leave it with

play05:00

everything check there and click Next

play05:02

it's going to put it put it in a pretty

play05:03

standard location under Program Files

play05:05

slash Arduino and then we click install

play05:08

I'm not going to pause the video because

play05:10

if you're playing along at home you can

play05:12

just download it right along with me I

play05:14

will enjoy a little coffee though it is

play05:20

going pretty quickly here and we're

play05:24

gonna get this downloaded we're gonna

play05:25

get connected to the Arduino and you are

play05:28

gonna write your first program I think

play05:31

you're gonna find it's a whole lot

play05:33

easier than what you think and you're

play05:35

gonna be wondering why have I waited so

play05:38

long to learn to program

play05:39

why have I learnt waited so long to

play05:42

learn a little engineering little

play05:43

computer science well at least you're

play05:46

doing it now ok happy the happy little

play05:49

blue bar is almost all the way across it

play05:52

says completed so now I will click close

play05:55

alright now the software has been

play05:58

installed so if I come down to little

play06:01

search bar or I guess on Windows 7 you

play06:03

could just click the button but I'm

play06:04

gonna say are do we know and there is

play06:08

the arduino app the happy little arduino

play06:11

app and i am going to that you just

play06:15

ignore what i'm doing here for a second

play06:17

okay i'm just gonna put it on my put it

play06:23

on my taskbar ok so here we go

play06:27

trying to get it yeah pin it to the

play06:29

taskbar in that way it'll be down here

play06:31

and be ready to roll when you need it

play06:34

but I can just click it from here this

play06:36

time and you see it is starting to open

play06:40

okay I'm going to switch over to a

play06:43

slightly different view here so that you

play06:47

will be able to see my code in my

play06:49

Arduino okay this Arduino is an Arduino

play06:52

that I just had laying around so I'm

play06:55

gonna unplug it and I'm gonna get out of

play06:57

my super starter kit I'm going to open

play07:02

it up with the little orange tabs and

play07:05

then what you will see is you will see

play07:08

right here on top top is a little

play07:10

envelope a little static envelope that

play07:13

has your Arduino in it so let's get that

play07:15

out and then you will need a USB cable

play07:20

which I already have here the other end

play07:24

of the USB cable is hooked to your PC

play07:27

the PC that you just installed the code

play07:29

on and then we have the Arduino so I

play07:33

will come over here and I will plug the

play07:36

Arduino in and what I hope is when I

play07:38

plug it in I hope that I hear a happy

play07:41

little noise okay I hear the happy

play07:43

little noise and what's that what that

play07:46

means is the PC is recognizing something

play07:49

that it understands has been plugged

play07:51

into the USB and so that means that

play07:53

things should really work from this

play07:55

point okay so now you have arduino ide

play08:00

open you have the arduino plugged in and

play08:04

so you need to call up a program called

play08:07

bare minimum because bare minimis is

play08:09

where you always start when you're

play08:11

writing a program so it has things that

play08:13

you will use in every program that you

play08:15

write so we will come to file we will

play08:19

come to examples we will come to basic

play08:24

we will come to bare minimum okay now

play08:32

you get this program this program shows

play08:35

you the two things that are part of

play08:37

every Arduino program

play08:39

the first is called the void setup the

play08:42

void setup begins with the open curly

play08:46

and it ends with the closed curly the

play08:49

commands that you put in void setup will

play08:51

be executed one time so you set the

play08:54

Arduino up in the void setup then the

play08:57

things that you want to run over and

play08:59

over those commands you put in the void

play09:01

loop the void loop starts with the open

play09:04

curly and ends with the closed curly B

play09:06

every Arduino program has a void setup

play09:10

every Arduino program has a void loop so

play09:15

this is what you're going to start with

play09:16

now the next thing is we have to make

play09:19

sure that we are talking to the Arduino

play09:22

from the IDE so we need to come up under

play09:25

tools and we need to come down to port

play09:28

and we can see that on mine it sees a

play09:32

com1 that might be the mouse or the

play09:34

keyboard or something but then it sees

play09:35

connected to comm 3 the Arduino or

play09:39

genuine Oh uno so it's season

play09:42

uno connected to that port now for you

play09:44

it's probably not going to be port 3 it

play09:46

could be port 7 or it could be port 25

play09:49

but the point is that it should be the

play09:51

one that recognizes that an Arduino is

play09:54

connected to it now let's just verify

play09:56

that that's true so you see comm 3 is

play09:58

Arduino Uno ok I'm going to come over

play10:01

here and I'm gonna unplug the Arduino

play10:06

right it's been unplugged now if I come

play10:09

to tools and I come to port com1 but

play10:14

doesn't see the Arduino why because we

play10:16

unplugged it ok things are working the

play10:19

way they should so we plug it back in we

play10:22

get the happy little USB noise and you

play10:27

can see some lights coming on on the

play10:28

Arduino seeing that it is in fact

play10:31

powering up and now if we come back to

play10:35

tools and we go to port we can see that

play10:38

the comm 3 is there now you need to go

play10:40

across and you need to select whatever

play10:43

comm port has the Arduino connected to

play10:46

it for me it's port 3 so we select that

play10:48

now we're connected to it alright the

play10:51

other thing that you need to do in your

play10:52

setup you need to

play10:53

make sure that on your board it matches

play10:55

the board that you're that you're using

play10:57

we're using the uno so we come down to

play10:59

Arduino Uno if you are using a nano you

play11:03

would come here or all the different

play11:04

Arduino let's just make sure that you

play11:06

select the board that you're using

play11:07

because if you don't you can have

play11:09

problems so we were on the Arduino Uno

play11:13

ladies and gentlemen we are ready to

play11:16

write our first program and it is as

play11:19

simple as this all right on this Arduino

play11:23

we want to do things without having to

play11:25

start building things so let's just

play11:27

write the simplest program possible do

play11:29

you see these pins along the edge of the

play11:32

Arduino it goes from pin zero they're

play11:34

labeled digital pins from pin zero to

play11:37

pin 13 these pins we can interact with

play11:40

we can send signals to the pins or we

play11:44

can pull signals off of the pins okay

play11:46

and so you can connect things up to

play11:49

these pins and then you can make the

play11:51

magic happen okay but I don't want to

play11:52

build circuits in this first lesson so

play11:55

the most excellent thing is if you look

play11:57

here and see this pin 13 that pin 13 is

play12:02

already hooked up to this little LED on

play12:05

the board so any signal that we send to

play12:08

pin 13 we are going to be sending to

play12:12

that little LED and so that allows us to

play12:14

write our first program without having

play12:17

to wire anything up or hook anything so

play12:20

first thing we got to do is we got to

play12:22

set the Arduino up what pins are we

play12:24

going to be working with we are going to

play12:26

be working with pin 13 so we have to

play12:29

tell Arduino we are working with 10 13

play12:32

we do that in the in the void setup and

play12:34

we do that with a pin mode Pyaar in

play12:38

capital M OD e pin mode you notice when

play12:42

I type in pin mode with the right

play12:44

capitalization it turns orange that's a

play12:46

happy thing that means that it

play12:48

recognizes the command so I'm going to

play12:50

tell it what I'm gonna do in my pin mode

play12:53

command open parenthesis now I have to

play12:55

put two parameters in the first

play12:58

parameter is which pin are you working

play13:00

with hmm which pen are we working with

play13:04

in 13

play13:06

ha then we put a comma and now we're

play13:10

going to have to give the second

play13:11

parameter the second parameter is we're

play13:13

telling the Arduino are we going to use

play13:15

pin 13 as an input or an output well

play13:19

we're going to send a signal to it so it

play13:21

is an output kind of like the printer

play13:23

right you send a document to the printer

play13:26

the printer is an output device we're

play13:28

gonna send a signal to pin 13 so pin 13

play13:32

becomes an output all-caps Oh UT P UT ah

play13:37

when I type it incorrectly what does it

play13:40

do it turns blue that's a happy little

play13:42

blue saying that it recognizes that

play13:44

parameter we now close our parentheses

play13:47

and almost all commands in arduino end

play13:51

with the semicolon we have now given our

play13:55

first command we're gonna execute it one

play13:57

time because it's in the void setup it's

play13:59

just gonna be telling arduino hey we're

play14:02

working with pin 13 it's gonna be an

play14:04

output all right so this is set up for

play14:08

the first program now let's go down to

play14:10

the void loop ha we're connected to that

play14:14

LED what would be neat if we did to that

play14:18

LED turn it on we want to turn the LED

play14:23

on so how would we turn the LED on where

play14:26

we've got to send a signal and the

play14:28

command is digit toll right again case

play14:33

is important digital is all lowercase

play14:36

the first letter of the next word W is

play14:39

capitalized so digital right this is

play14:42

called bumpy font where the first letter

play14:45

of the words are capitalized because you

play14:48

don't want to use spaces and so you can

play14:50

kind of read it better digital write but

play14:53

notice that if I did it wrong digital

play14:55

write and capitalized wrong we don't get

play14:58

the happy little orange color so if it

play15:00

doesn't light up you know you've done

play15:01

something wrong ah I didn't capitalize

play15:03

the dub u WR ite

play15:06

okay we have to give it again two

play15:09

parameters we've got to open hmm what

play15:13

pen are we gonna write to that's the

play15:15

first parameter pin 13

play15:18

and then second do we want to turn it on

play15:21

or do we want to turn it off well we

play15:24

want to turn the LED on so the command

play15:26

that we would give the parameter we

play15:27

would use is high we're gonna set it

play15:30

high means 5 volts we're gonna set pin

play15:32

13 to 5 volts so I type in hig H all

play15:37

caps when I do it in all caps its happy

play15:39

it turns blue if you do this you see no

play15:43

happy no blue so you've got to get your

play15:46

case right hi what do we do at the end

play15:49

of almost every command in Arduino the

play15:52

semicolon okay so what does this do in

play15:55

the void setup it tells the Arduino that

play15:58

we will be using pin 13 it's going to be

play16:00

an output and then in the loop we say

play16:02

hey take pin 13 turn it high that should

play16:05

turn the LED on now right now this

play16:08

program is here in your PC we now want

play16:13

to send it down through the USB cable

play16:16

down into the Arduino and you do that

play16:20

with this little arrow here this little

play16:23

right arrow you're gonna click on that

play16:25

and then it's going to send your code

play16:27

down into your Arduino so when I click

play16:29

on that I look here and I get a happy

play16:31

little green bar meaning that it's

play16:33

recognizing the commands it's compiling

play16:36

it and when that green bar goes away it

play16:39

means the program is down in the Arduino

play16:41

and look what happened here on the

play16:44

Arduino boom the LED turned on you have

play16:48

written your first program and you have

play16:51

controlled an item you have turned an

play16:53

LED on mm-hmm

play16:56

maybe we should write a second program

play16:58

what should the second program do mmm

play17:02

turn the LED off I want you to guess if

play17:08

I turned it on what do you think would

play17:11

turn it off no L Oh W all uppercase so

play17:18

now how do we download the program into

play17:20

the Arduino we come up to this little

play17:21

right arrow we click on the right arrow

play17:23

boom it goes down and what happens the

play17:27

LED was turned off you have written your

play17:30

second program

play17:32

you can turn the LED on you can turn the

play17:35

LED off well if you hooked other things

play17:37

up to pin 13 already today you could be

play17:40

turning them on and off and so even

play17:42

though this is really simple it's very

play17:44

very powerful now I want you to think

play17:46

let's turn it back on so I'm gonna go

play17:48

back hi okay hi download it in the LED

play17:56

is on okay if I can turn the LED on and

play17:59

I can turn the LED off what could I do

play18:03

in program 3 I can make it blink how

play18:07

would you make it blink well you

play18:10

digitalwrite 13 hi and then you have a

play18:13

new command digit told digit all right

play18:17

what pen are we working with 13 and now

play18:20

we can want to make it go low so we're

play18:24

gonna turn it on and off and then it

play18:26

should blink so we come up we download

play18:29

the program and it goes ooh wait a

play18:34

minute it's not blinking no blinky okay

play18:39

hmm what could be wrong all right think

play18:45

about this does a computer do things

play18:47

quickly or does the computer do things

play18:50

slowly it does it quickly very quickly

play18:52

so what are you doing with this program

play18:53

that you just wrote you're turning it so

play18:59

quickly your eye cannot perceive that

play19:01

it's blinking it just looks like it's

play19:03

kind of dim okay and so the problem is

play19:06

you're blinking it so fast that you

play19:09

can't see it so you need a new command

play19:10

what command do you need you need to be

play19:13

able to put a delay in your program

play19:16

where you turn the LED on you delay you

play19:21

turn the LED off you delay so let's add

play19:25

another command after the turn it on

play19:28

what do we want to do we want to delay

play19:30

the command is wait for it delay you

play19:34

spell it right you get the happy orange

play19:37

open promote open parenthesis we got to

play19:40

give it one parameter and that's how

play19:42

many milliseconds you want to delight

play19:44

okay

play19:46

there's a thousand milliseconds in a

play19:48

second so if we want to leave it on for

play19:51

one second that would be how many

play19:52

milliseconds 1000 milliseconds is one

play19:56

second don't forget the semicolon II

play20:00

okay so we turn it on we wait a thousand

play20:03

we turn it off and what should we do

play20:05

wait a thousand so what this is what is

play20:11

this going to do turn the LED on for a

play20:14

second

play20:15

turn it off wait a second turn it on

play20:18

wait a second turn it off wait a second

play20:20

so it should be a pretty slow blink here

play20:22

how do we get this most excellent

play20:24

program down into the Arduino we click

play20:26

the right arrow we watch our little LED

play20:29

and look at that off on on it's blinking

play20:35

exactly like we told it to okay now do

play20:39

we have to blink balance like that no

play20:41

let's leave it on for a tenth of a

play20:44

second and then let's leave it off for

play20:47

nine tenths of a second so the duty

play20:49

cycle is going to be one second but this

play20:52

the LED is going to be on for a tenth

play20:54

and off for a 9/10 what would a tenth of

play20:58

a second be well a thousand milliseconds

play21:01

is one second so a tenth of a second

play21:04

would be a thousand divided by 10 which

play21:05

is a hundred and then we want it to be

play21:08

off for nine hundred so still it's good

play21:14

the duty cycle is going to be one second

play21:15

but it's going to be oh no ha ha ha like

play21:21

that

play21:21

ok so let's download it and let's see

play21:24

what happens uh uh ok let's do it the

play21:32

other way let's have it mostly on 900 on

play21:39

100 ah let's download that so this is

play21:44

gonna be uh on off on off you see it's

play21:51

mainly on it's mainly on I might have

play21:53

messed that up a little bit but I'm

play21:54

sorry right so hopefully yours is

play21:57

hopefully yours is doing that man

play21:59

you've written your first three programs

play22:01

and it's just your first lesson and

play22:03

you've already written three programs

play22:05

okay let me give you a couple of

play22:08

assignments I want you to first of all

play22:12

what I want you to do is I want you to

play22:15

write a program where it will blink fast

play22:20

and I want you to see how quickly you

play22:23

can make it blink where your eye still

play22:25

perceives that it's blinking okay so

play22:28

let's say let's say if I put 500 and 500

play22:35

that's a half a second on and a half a

play22:37

second off all right and then if I look

play22:40

at it I can clearly see that that's

play22:42

blinking but as you make that number

play22:44

smaller and smaller you're gonna reach a

play22:47

point that your eye cannot perceive that

play22:49

it's blinking and it's just gonna look

play22:51

like a constant maybe somewhat dim LED

play22:55

so what I want you to do is I want you

play22:57

to do that experiment and see how low

play23:00

you can make this number how fast you

play23:03

can make it blink you've got to change

play23:04

both of them and still perceive that

play23:07

it's blinking and then put your results

play23:09

down in the comments and let's see if

play23:10

you guys are getting similar answers as

play23:13

far as your eye perceiving that the

play23:15

thing is blinking versus it just looks

play23:17

like it's it's constant okay guys this

play23:21

is public order from Coptic boy comm if

play23:23

you like this video give us a thumbs up

play23:26

think about subscribing to the channel

play23:27

maybe sharing it with people if you

play23:30

haven't already get your kit and follow

play23:32

along with me leave your comments down

play23:35

below really love to hear from you guys

play23:37

love to get your comments and your

play23:40

feedback so hopefully you will do that

play23:42

this is Palmer quarter from top tech boy

play23:45

comm I will talk to you guys later

Rate This

5.0 / 5 (0 votes)

Related Tags
ArduinoProgrammingTutorialsMicrocontrollerDIYTech EducationHardwareSoftwareLED ControlBlinking LEDEngineering