Articles Posted by the Author:

  • min()

    min()

      min(x, y) Description Calculates the minimum of two numbers. Parameters x: the first number, any data type y: the second number, any data type Returns The smaller of the two numbers. Examples sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100 // ensuring that it never gets above 100. […]


  • delayMicroseconds()

    delayMicroseconds()

      delayMicroseconds() Description Pauses the program for the amount of time (in microseconds) specified as parameter. There are a thousand microseconds in a millisecond, and a million microseconds in a second. Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a […]


  • delay()

    delay()

      delay() Description Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a second.) Syntax delay(ms) Parameters ms: the number of milliseconds to pause (unsigned long) Returns nothing Example int ledPin = 13; // LED connected to digital pin 13 void setup() { pinMode(ledPin, OUTPUT); // […]


  • micros()

    micros()

      micros() Description Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of […]


  • millis()

    millis()

      millis() Description Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Parameters None Returns Number of milliseconds since the program started (unsigned long) Example unsigned long time; void setup(){ Serial.begin(9600); } void loop(){ Serial.print("Time: "); time = […]


  • pulseIn()

    pulseIn()

      pulseIn() Description Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no […]


  • shiftIn()

    shiftIn()

      shiftIn() Description Shifts in a byte of data one bit at a time. Starts from either the most (i.e. the leftmost) or least (rightmost) significant bit. For each bit, the clock pin is pulled high, the next bit is read from the data line, and then the clock pin is taken low. Note: this […]


  • shiftOut()

    shiftOut()

      shiftOut() Description Shifts out a byte of data one bit at a time. Starts from either the most (i.e. the leftmost) or least (rightmost) significant bit. Each bit is written in turn to a data pin, after which a clock pin is pulsed (taken high, then low) to indicate that the bit is available. […]


  • noTone()

    noTone()

      noTone() Description Stops the generation of a square wave triggered by tone(). Has no effect if no tone is being generated. NOTE: if you want to play different pitches on multiple pins, you need to call noTone() on one pin before calling tone() on the next pin. Syntax noTone(pin) Parameters pin: the pin on […]


  • tone()

    tone()

      tone() Description Generates a square wave of the specified frequency (and 50% duty cycle) on a pin. A duration can be specified, otherwise the wave continues until a call to noTone(). The pin can be connected to a piezo buzzer or other speaker to play tones. Only one tone can be generated at a […]