3.2 BASIC OPERATIONS AND FUNCTIONS

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/47

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

48 Terms

1
New cards
void setup(); void loop ()
The basic structure of the Arduino programming language is fairly simple and runs in at least two functions:
2
New cards
preparation
void setup()
3
New cards
execution
void loop()
4
New cards
Setup function
should follow the declaration of any variables at the very beginning of the program
5
New cards
Setup function
first function to run in the program, is run only once, and is used to set pinMode or initialize serial communication
6
New cards
Loop function
follows next and includes the code to be executed continuously – reading inputs, triggering outputs, etc.
7
New cards
Loop function
the core of all Arduino programs and does the bulk of the work
8
New cards
Functions
A block of code that has a name and a block of statements that are executed when the function is called
9
New cards
Functions
Can be written to perform repetitive tasks and reduce clutter in a program
10
New cards
Curly braces
Define the beginning and end of function blocks and statement blocks such as the void loop() function and the for and if statements
11
New cards
Semicolon
Must be used to end a statement and separate elements of the program
12
New cards
Semicolon
Also used to separate elements in a for loop
13
New cards
Block comments
Used for large text descriptions of code or comments that help others understand parts of the program
14
New cards
Block comments
Begin with /\* and end with \*/ and can span multiple lines
15
New cards
Line comments
Begin with // and end with the next line of code.
16
New cards
Variables
A way of naming and storing a numerical value for later use by the program
17
New cards
Locally declared variable
Defined inside a function or as part of a for loop
18
New cards
Globally declared variable
Can be seen and used by every function and statement in a program
19
New cards
Globally declared variable
Declared at the beginning of the program, before the setup() function
20
New cards
byte
stores an 8-bit numerical value without decimal points. They have a range of 0- 255.
21
New cards
int
primary datatype for storage of numbers without decimal points and store a 16-bit value with a range of 32,767 to -32,768.
22
New cards
long
Extended size datatype for long integers, without decimal points, stored in a 32-bit value with a range of 2,147,483,647 to -2,147,483,648.
23
New cards
float
A datatype for floating-point numbers, or numbers that have a decimal point.
24
New cards
float
have greater resolution than integers and are stored as a 32-bit value with a range of 3.4028235E+38 to -3.4028235E+38.
25
New cards
Arithmetic
include addition, subtraction, multiplication, and division
26
New cards
Constants
few predefined values
27
New cards
true/false
Boolean constants that define logic levels.
28
New cards
high/low
Define pin levels as ___ or ___ and are used when reading or writing to digital pins
29
New cards
input/output
Constants used with the pinMode() function to define the mode of a digital pin as either ___ or ___
30
New cards
Flow control
Statements used to alter the flow of code
31
New cards
if
Test whether a certain condition has been reached, such as an analog value being above a certain number, and executes any statements inside the brackets if the statement is true
32
New cards
if else
Allows for ‘either-or’ decisions to be made
33
New cards
for
Used to repeat a block of statements enclosed in curly braces a specified number of times
34
New cards
while
Will loop continuously, and infinitely, until the expression inside the parenthesis becomes false
35
New cards
while
Something must change the tested variable, or the while loop will never exit
36
New cards
do while
A bottom driven loop that works in the same manner as the while loop, with the exception that the condition is tested at the end of the loop, so the do loop will always run at least once
37
New cards
pinMode
Used in void setup() to configure a specified pin to behave either as an INPUT or an OUTPUT
38
New cards
digitalRead
Reads the value from a specified digital pin with the result either HIGH or LOW
39
New cards
digitalWrite
Outputs either logic level HIGH or LOW at (turns on or off) a specified digital pin
40
New cards
analogRead
Reads the value from a specified analog pin with a 10-bit resolution
41
New cards
analogRead
Only works on the analog in pins (0-5). The resulting integer values range from 0 to 1023.
42
New cards
analogWrite
Writes a pseudo-analog value using hardware enabled pulse width modulation (PWM) to an output pin marked PWM.
43
New cards
pulse width modulation
aka PWM
44
New cards
analogWrite
The value can be specified as a variable or constant with a value from 0-255
45
New cards
delay
Pauses a program for the amount of time as specified in milliseconds, where 1000 equals 1 second
46
New cards
millis
Returns the number of milliseconds since the Arduino board began running the current program as an unsigned long value
47
New cards
Serial.begin
Opens serial port and sets the baud rate for serial data transmission
48
New cards
Serial.println
Prints data to the serial port, followed by an automatic carriage return and line feed