

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
void function(){}: defines a function as the commands found between the curly braces that will not return a value. ○ function: name of the function, ...
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


delay( value ): waits a noted amount of time before moving on to following commands ● value: a number denoting time in milliseconds (1000 milliseconds = 1 second) digitalWrite( variable , setting ): sets a component to on (HIGH) or off (LOW) ● variable: name of the component ● setting: Either HIGH or LOW digitalRead( variable ): returns the value of a noted component, either HIGH or LOW ● variable: name of the component analogWrite( variable , value ): sets a component to a certain value from 0- ● variable: name of the component ● value: A number 0- NOTE: can only be used when a component is plugged into a pin with ~symbol analogRead( variable ): returns the value of a noted component, a number 0- ● variable: name of the component NOTE: can only be used when a component is plugged into a pin with ~symbol
int variable = value : creates an integer variable and assigns it a value ● variable: name of the variable written in camelCase ● value: A whole number (positive or negative) void function (){}: defines a function as the commands found between the curly braces that will not return a value ● function: name of the function, written in camelCase ● To call the function, simply write the function name and a set of parentheses, ie. myFunction(); ● Parameters can be included in the parentheses int function (){}: defines a function as the commands found between the curly braces that will return an integer ● function: name of the function, written in camelCase ● To call the function, simply write the function name and a set of parentheses, ie. myFunction(); ● Parameters can be included in the parentheses
if (condition) { commands; } else if (condition) { commands; } else { commands; } Example: if (digitalRead(button) == HIGH) { digitalWrite(motor, HIGH); } else { digitalWrite(motor, LOW); }
digitalRead( component ): returns the digital value of a component as 1 (on) or 0 (off) ● component: name of the component to be checked analogRead( component ): returns the analog value of a component ● component: name of the component to be checked
for (initialization; condition; increment) { commands; } Example: for (int i = 0; i < 4; i++) { analogWrite(redLED, count); count+=50; }
while (condition) { commands; } Example: while (digitalRead(button) == LOW) { digitalWrite(redLED, HIGH); } digitalWrite(redLED, LOW);
Mathematical Operators Comparison Operators Logical Operators + addition == Equal to! Not
- subtraction != Not equal to && And ***** multiplication < Less than || Or / division <= Less than or equal to % > Greater than >= Greater than or equal to