All Projects / Tutorial / Creating a For Loop
Creating a For Loop
0 votes
Sign In to add your vote
DOWNLOAD NOW!
DIFFICULTY
DESCRIPTION
Here's the basic structure for creating a For loop using Teagueduino. This lets you perform an action an exact number of times.

For example, maybe you'd like to blink a light 5 times.

The For loop in C look would look something like this:

for(int i=0; i<5; i++){
// turn light on
// delay for .2 seconds
// turn the light off
// delay for .2 second
}

In Teagueduino, we can use variables to accomplish the same thing like this:

Var_1 = 0 + 0;
while(Var_1 < 5){
Out_A = 1000 as PWM;
delay(200);
Out_A = 0 as PWM
delay(200);
Var_1 = Var_1 + 1;
}
THE CODE
Setup
Main Program
WHAT YOU NEED
1:

2:

3:

4:

5:

A:
LED

B:

C:

D:

E:

CREDITS
Built by
Teague Labs
Posted by
Adam Kumpf
Derived from
Creating a For Loop
Views
2307
Downloads
131