LESSON 2 Flashcards
What is a logic statement?
In coding, a logic statement is where the code has to pick between something being TRUE or FALSE. This allows us to make our code and products more complex and allows us to do more things.
What is the simplest logic statement and it’s structure?
The simplest logic statement is called an IF/ELSE statement.
IF (something is true) {
Do something;
}
ELSE {
Do something else;
}
What commands are in C++ coding?
Void setup
pinMode - Activates a specific pin as INPUT or OUTPUT
serial.Begin - Opens Serial Monitor/Output screen
Void Loop
analogWrite - Send power to (You determine the amount of power)
digitalWrite - Send Power to (Either HIGH or LOW)
digitalRead - Check this and tell me if there’s power (Either HIGH or LOW)
serial.Write - Write this message on the output screen
serial.Print Writes the output value on the output screen
delay - wait
What are the other logic statements and their structures?
Another type of logic statement is the FOR statement. This allows us to iterate through a series of things.
FOR (declare an iterator; set a condition; increase or decrease) {
DO something with the iterator
Increase the iterator by some amount
Check whether the condition is TRUE or FALSE
}
The third type of logic statement is the WHILE statement. This allows us to repeat through a series of things until a condition is false. (The series could repeat infinitely.)
WHILE (make a condition and set it to TRUE) {
Do something;
Check whether the condition is still true;
}