Pages

Tuesday, October 29, 2013

A short list of Arduino Key Words

A short list of Arduino C Keywords

The following list is based upon the keywords found in the more commonly used Arduino Example Sketches.

Variable Types

·         int

·         float

·         long

Variable Type Modifier

·         const

·         unsigned

Serial Library

·         Serial.begin( … )

·         Serial.print( … )

·         Serial.println( … )

Sevo Library

·         #include <Servo.h>             (must be placed at beginning of sketch)

·         Servo servoName                (each servo must be given a unique identifier)

·         servoName.attach( … )      (must be attached to a PWM pin)

·         servoName.write(val)       (val must be between 0 and 180)

Modes

·         INPUT

·         OUTPUT

·         HIGH

·         LOW

·         INPUT_PULLUP

Defined Functions

·         setup()

·         loop()

·         analogRead( …   )

·         analogWrite( …   )

·         delay( … )

·         digitalWrite( … )

·         digitalRead( … )

·         millis( … )

·         pinMode( … )

Conditionals

·         if

if (someVariable > 50)

{

  // do something here

}

 

·         if  /  else

if (someVariable > 50)

{

  // action A

}

else

{

  // action B

}

 

·         while

var = 0;

while(var< 200)
{

  // do something repetitive 200 times

  var++;

}

 

·         for

for (int i=0; i <= 255; i++)

{

    Serial.println(i);

}

 

Comparison Operators

·         x == y      (x is equal to y)

·         x != y       (x is not equal to y)

·         x <  y        (x is less than y) 

·         x >  y        (x is greater than y)

·         x <= y      (x is less than or equal to y)

·         x >= y      (x is greater than or equal to y)

Boolean Operators

·         &&           and

·         ||             or

·         !                not

 

Special Items

·         void – this is only used in function declarations. It indicates that the function is expected to return no information to the function from which it was called.

Arrays

·         An array is a collection of variables that are accessed with an index number.

·         Declaring an array

int myArray[] = {2, 4, 8, 3, 6};

·         Accessing an array

myArray[0]      contains 2

myArray[4]      contains 6

myArray[5]      is invalid and will return random information