Aurdino Programming Commands Reference Guide

Aurdino Programming Commands Reference Guide [Library Functions]

We have seen in detail about what is Aurdino? How to do Aurdino Program? in our previous posts. In this post, let’s see the most important and basic commands/functions that are defined already. 

  1. Digital I/O
  2. Analog I/O
  3. Time
  4. Math
  5. Random
  6. Serial

They are often used in the Aurdino projects. Let us see them one by one in detail:

Digital I/O Commands

digitalRead(pin) :

  • This function reads the value from a digital pin that have the result either HIGH or LOW.
  • This pin can be specified as either a variable or constant. Here constant refers 0-13.

Syntax:

digitalWrite(pin) :

  • Set a digital pin to output mode. Output can be either HIGH or LOW (led pin turns on or off) based on this pin value.
  • The pin is specified as either a variable or constant (0-13).

Syntax:

Example:

Analog I/O Commands:

analogRead(pin):

  • This reads the value from an analog pin  with a 10 bit resolution  that is  specified.
  • This function works only on the analog pins (0-5).
  • The resulting integer value ranges from 0 to 1023.

Syntax:

Note: Here analog pins need not to be declared as input or output in the starting of program like digital pins.

analogWrite(pin,value)

  • This code writes a psuedo-analog value using hardware enabled pulse width modulation (PWM) to an output pin marked PWM.
  • This value can be declared as a variable or constant with a value from 0-255.
  • The older versions of Aurdino supports on the pins 9,10,11.
  • But the newer versions supports 3,5,6,9,10 and 11 pins.

Syntax:

Example:

Time related commands:

delay(ms) :

    • This code helps to keep the running program in Pause for the time specified in milliseconds.
    • Here note that 1 second = 1000 milliseconds.

Example:

millis() :

    • This is the time in milliseconds that the Aurdino board began running the current program as an unsigned long value.

Syntax:

Note: This number gets overflow after approximately 9 hours. i.e., reset back to zero after 9 hours.

Math commands:

max(x,y):

  • This function calculates the maximum of two numbers of any data type and returns the small number.

Example:

 min(x,y):

  • This function calculates the minimum of two numbers of any data type and returns the greater number.

Example:

Special Commands [Random]:

randomSeed(seed)

  • Sets the value or seed as the starting point for the random() function.

Syntax:

Why use randomSeed()?

  • The Aurdino is unable to create a truly random number. 
  • This randomSeed allows you to place a variable, constant or other function into random function.
  • This helps to generate more random numbers. 

random(min,max):

  • The random function returns pseudo-random numbers within a range specified in min and max values.

Example:

Note: This function should be used only after randomSeed() function.

Serial communication commands:

Serial.begin(rate):

  • This is a special function that opens up the serial port and sets the baud rate for serial data transmission.

Note: The typical baud rate for communicating with the compute is 9600, even though the other speeds are supported. Also you cannot use both pins 0 and 1 at the same time.

Serial. println(data) :

  • This is same as Serial.print(). But it is easier for reading data on Serial monitor.
  • Prints data to the serial port, followed by an automatic carriage return and line feed. 

Syntax:

These are the basic commands that are used frequently in most of the Aurdino programs.

You may also like to read:

Top  5 Aurdino Projects 
Difference between C and Embedded C
Aurdino LED Binary Counter

Thanks for reading….. Please leave your comments below….

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *