Loading…
Transcript

analogRead();

This instruction is used to read an analog value fron an input pin in snowball board

We can use analogRead() with :

Nested Conditions

if(condition){

if(condition2){

Statement(s);

}

}

Here the statement(s) will be performed if the 2 conditions are true

Today we are going to learn

Loops

Nested Conditions

analogRead();

Nested Loops

Level 5 Session 3

loops

In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.

For Loop

While Loop

The for statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop.

while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false.

for (initialization; condition; increment) {

//statement(s);

}

while (expression) {

// statement(s)

}

Do ... While Loop

The do loop 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.

do

{

// statement block

} while (test condition);

What's Next !!