Articles Posted in the " " Category

  • do – while

    do – while

    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); Example Language Reference Home The text of the 86Duino […]


  • break

    break

    break is used to exit from a do, for, or while loop, bypassing the normal loop condition. It is also used to exit from a switch statement. Example Language Reference Home The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code […]


  • return

    return

    Terminate a function and return a value from a function to the calling function, if desired. Syntax return; return value; // both forms are valid Parameters value: any variable or constant type Example A function to compare a sensor input to a threshold The return keyword is handy to test a section of code without […]


  • continue

    continue

    The continue statement skips the rest of the current iteration of a loop (do, for, or while). It continues by checking the conditional expression of the loop, and proceeding with any subsequent iterations. Example Language Reference Home The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a […]


  • goto

    goto

    Transfers program flow to a labeled point in the program Syntax label: goto label; // sends program flow to the label Tip The use of goto is discouraged in C programming, and some authors of C programming books claim that the goto statement is never necessary, but used judiciously, it can simplify certain programs. The […]


  • while loops

    while loops

    Description while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. This could be in your code, such as an incremented variable, or an external condition, such as testing a sensor. Syntax while(expression){    // statement(s) […]


  • switch / case statements

    switch / case statements

    Like if statements, switch...case controls the flow of programs by allowing programmers to specify different code that should be executed in various conditions. In particular, a switch statement compares the value of a variable to the values specified in case statements. When a case statement is found whose value matches that of the variable, the […]


  • for statements

    for statements

    Description 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. The for statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins. There are three parts […]


  • if / else

    if / else

    if/else allows greater control over the flow of code than the basic if statement, by allowing multiple tests to be grouped together. For example, an analog input could be tested and one action taken if the input was less than 500, and another action taken if the input was 500 or greater. The code would […]


  • if (conditional) and ==, !=, <, > (comparison operators)

    if (conditional) and ==, !=, <, > (comparison operators)

    if, which is used in conjunction with a comparison operator, tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is: The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put […]