The Induino R3 / Arduino Uno Boards have 20 programmable I/O's. These are Pins 0 to 13 and Pins 0 to 5 [Analog In 0 to 5]. For reference sake, we will refer to the pins Analog In 0 to 5 as A0 to A5
All of the 20 I/O's can be used for working with Digital Signals - They can both take Digital Inputs & produce Digital Ouput. The Pins marked A0 to A5 [Analog In 0 to 5] When being used for working with Digital Inputs / Outputs are referred to as 14 to 19. So when working with Digital Inputs / Outputs, the pins are numbered from 0 to 19 (0 to 13 & 14(A0) to 19(A5)). The Digital Pins can be used for controlling LED's, Relays, Etc and for Taking input from Push-Buttons, Digital Sensors, Etc.
The pins A0 to A5 [Analog In 0 to 5] are pins dedicated for working with Analog Inputs. They have in inbuilt Analog to Digital Converter that will convert analog voltages in the range of 0 to 5 volts to a 10-bit value. They can be used for working with Analog Sensors - Temperature, Light, Etc.
The six pins 3,5,6,9,10 & 11 marked PWM are pins dedicated to produce Analog Output Signal. They can produce analog voltages in the range of 0 to 5 volts with a resolution of 8-bits. They can be used for Intensity Control, Speed Control, Etc.
There are 2 external Interrupts available on the Induino R3 / Arduino Uno Boards. These are on pins 2 & 3. These pins are used to configure external interrupts. They can be used to connect digital inputs like alarm switch, etc.
The Arduino Boards, provide a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). A FT232RL IC on the board channels this serial communication over USB and appears as a virtual com port to the computer. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip
I2C Communication a.k.a Two Wire Communication
The Atmega328 provides I2C / Two Wire Communication through the Analog Pins A4 (SDA) & A5 (SCL). The Arduino software includes a Wire library to simplify use of the I2C bus. I2C Communication can be used for communicating with other microcontrollers / ICs - Like the Real Time Clock IC DS1307.
The Atmega328 supports SPI communication through pins 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). SPI communication is supported by the Arduino IDE using the SPI library. SPI Communication can also be used to communicating with other peripherals / ICs - SD Cards, Ethernet Controller, Etc.
In addition to the Hardware Serial Communication provided by the ATmega328, The Software Serial Library for Arduino will let us use any pin on an Arduino for additional Serial Communication.
Reference voltage for the analog inputs. By default the ADC uses 5 Volts as the reference voltage, However you can change this by providing a suitable voltage between 0 to 5 Volts on this line.
This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V. This pin is used for shield compatibility.
This pin is for using external Reset circuitry to reset the board. Bring this line LOW to reset the microcontroller.
There are three types of Memories available on the ATmega328
- Flash memory (32KB, of which .5k is used for the bootloader) - is where the program is stored.
- SRAM (static random access memory - 2KB) - is where the program creates and manipulates variables when it runs.
- EEPROM (1 KB) - is memory space that programmers can use to store long-term information.
Arduino Provides with a number of Libraries to work with the different types of memories.
The Arduino IDE
The Arduino IDE (Integrated Development Environment) is a piece of software that helps you program various Arduino / Induino Boards. Here's the best possible overview of the IDE
When working with the InduinoR3 Board, you need to select the board as Arduino UNO from the Tools-> Boards List and Select the Appropriate Com Port (The COM port that you got after the FTDI driver installation)
The Arduino IDE comes with a number of libraries however if you want to install additional libraries, check this -> http://arduino.cc/en/Guide/Libraries
The Bootloader is a piece of Software that is loaded on to the ATmega 328 to facilitate programming of the ATmega328 from within the Arduino IDE. The Bootloader is loaded initially when the board is powered on / reset. The Bootloader waits for a few moments looking for an signal from the Arduino IDE indicating a new program needing to be uploaded to the IC. If it receives the Signal, it receives the new program over Serial communication and writes it onto the program memory of the ATmega328. If it doesn't receive any such signal it proceeds to load the existing program present in the program memory of the ATmega328. There are a number of Arduino Bootloaders available depending upon the microcontroller, the operating voltage and the type of crystal oscillator used.
The programming in Arduino IDE is much similar to 'c' programming. You can look at the programming reference for an overview of what is supported and what is not.
setup() and loop()
There are two special functions that are a part of every Arduino sketch: setup() and loop(). The setup() is called once, when the sketch starts (either at Power On or at Reset). The setup() function is used to do one time configurations that are required at power on. The loop() function is where your application code would go into. As the name signifies the loop() function is infact a loop that keeps running on and on till the board is powered off. You need to include both functions in your sketch, even if you don't need them for anything.
Almost all data types are supported. The Reference is a good point to start with on Data Types. Scope of the variable is same as in 'c' programming. Remember that a variable created in the setup() function will not be available in the loop () function and that a variable declared inside the loop() will keep getting recreated for every iteration of the loop() funciton.
Basic Arduino Programming Structure
/* Comments */
// Library Inclusions - if Any libraries are to be included
// Basic One Time Power On Configurations
// Application Code