subrutine

How can i call a subrutine,a section of my program is repeatted a lot of time?

//the loop() function is called by arduino. when it ends it is called again, and again and again...
int i=0;
void loop()
{
//call a subroutine
DoSomething();
//and another one
DoSomethingElse();

//or you can make your own looping. we loop 10 times
int n=0;
for(n=0;n<10;n++)
{
DoSomething();
DoSomethingElse()
}

}

void DoSomething()
{
//do some stuff here
i++;
}

void DoSomethingElse()
{
//do some stuff here
i--;
}

//the code above should add 1 to i and then subtract 1 from i continuously

1 Like

Do you have any programming experience and if so, in what language(s)? This is so basic that it'd help to know at what level to answer...

If I recall correctly from many years ago, I think BASIC used the term "subroutine". Beginner questions are okay, we were all beginners once.