Programming Arduino Getting Started with Sketches



Yüklə 5,42 Kb.
Pdf görüntüsü
səhifə16/78
tarix22.12.2023
ölçüsü5,42 Kb.
#189286
1   ...   12   13   14   15   16   17   18   19   ...   78
Arduino SimonMonk 2011

digitalWrite
,
not 
DigitalWrite
or 
Digitalwrite.
The function 
digitalWrite
needs to know which pin to set and whether to set that pin
HIGH or LOW. These two pieces of information are called 
arguments
, which are said to
be 
passed
to a function when it is 
called
. The parameters for a function must be enclosed
in parentheses and separated by commas.
The convention is to place the opening parenthesis immediately after the last letter of
the function’s name and to put a space after the comma before the next parameter.
However, you can sprinkle space characters within the parentheses if you want.
If the function only has one argument, then there is no need for a comma.
Notice how each line ends with a semicolon. It would be more logical if they were
periods, because the semicolon marks the end of one command, a bit like the end of a
sentence.
In the next section, you will find out a bit more about what happens when you press the
Upload button on the Arduino integrated development environment (IDE). Then you will
be able to start trying out a few examples.
What Is a Programming Language?
It is perhaps a little surprising that we can get to 
Chapter 3
 in a book about programming
without defining exactly what a programming language is. We can recognize an Arduino
sketch and probably have a rough idea of what it is trying to do, but we need to look a bit
deeper into how some programming language code goes from being words on a page to
something that does something real, like turn an LED on and off.
Figure 3-1
summarizes the process involved from typing code into the Arduino IDE to
running the sketch on the board.


Figure 3-1
From code to board
When you press the Upload button on your Arduino IDE, it launches a chain of events
that results in your sketch being installed on the Arduino and being run. This is not as
straightforward as simply taking the text that you typed into the editor and moving it to the
Arduino board.
The first step is to do something called 
compilation
. This takes the code you have
written and translates it into machine code—the binary language that the Arduino
understands. If you click the triangular Verify button on the Arduino IDE, this actually
attempts to compile the C that you have written without trying to send the code to the
Arduino IDE. A side-effect of compiling the code is that it is checked to make sure that it
conforms to the rules of the C language.
If you type 

Yüklə 5,42 Kb.

Dostları ilə paylaş:
1   ...   12   13   14   15   16   17   18   19   ...   78




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin