Introduction to arduino board IoT Experiments Uncategorized by Ravinder Nath Rajotiya - November 4, 2024November 4, 20240 Share on Facebook Share Send email Mail Print Print Table of Contents Toggle Experiment-1 : Introduction to Arduino platform and programmingObjective: Requirement : Theory: Arduino Pin DiagramDigital Input Output Pins :Microprocessor Atmega 328PIntegrated Development EnvironmentThe Arduino Software (IDE):Installation of Arduino Software (IDE)Arduino SketchSelecting Board and the PortCompiling and Uploading the Sketch:Arduino Program structure Experiment-1 : Introduction to Arduino platform and programming Objective: At the end of this experiment We will be able to: Understand the Arduino board, its pin names and uses. Understand the Software IDE and the programming environment Understand the compilation and Uploading of the Program on hardware. Requirement : PC with internet, Arduino board, breadboard Theory: Arduino UNO is a microcontroller board based on the ATmega328P (datasheet). It is one of the finest platform for learning and prototyping IoT, embedded projects, automation etc. The board has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller. To start working you can simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. There are many variants of the Arduino boards, some of them being: Entry level boards like the UNO, LEONARDO, NANO etc; Boards with enhanced feature like the MEGA, PRO, ZERO etc; Boards for Internet of Things like the YUN, TIAN etc; Wearable boards like the LILYPAD, GEMMA etc. Arduino Pin Diagram Arduino pins are multiplexed meaning that most of the pins are multi-function. Also the 6-pin header at the bottom and also at the top right corner near the USB socket are multifunction. Arduino Uno Board Configuration Digital Input Output Pins : Arduino Uno has 14 digital input output pins numbered 13 through 0. These ping can carry a continuous 20mA or max 40mA. These pins have additional function. Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip. External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attach Interrupt() function for details. PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function. SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library. LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off. TWI(I2C): A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library. The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analog Reference() function. There are a couple of other pins on the board: AREF. Reference voltage for the analog inputs. Used with analog Reference(). Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board. The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino Software (IDE) includes a Wire library to simplify use of the I2C bus; see the documentation for details. For SPI communication, use the SPI library Microprocessor Atmega 328P The main IC on the Arduino board is the microprocessor Atmega-328P. It is an 8-bit microprocessor having on-chip 32KB flash memory, 1KB EPROM and 2 KB SRAM. The figure below shows the mapping of the Arduino and the Atmega-328P microprocessor. Mapping of the Arduino and the Atmega-328P microprocessor IC Integrated Development Environment Introduction: The Arduino Software (IDE) is easy-to-use and is based on the Processing programming environment. The Arduino Integrated Development Environment (IDE) is a cross-platform application (for Windows, macOS, Linux) that is written in functions from C and C++. The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. This software can be used with any Arduino board. The Arduino Integrated Development Environment – or Arduino Software (IDE) – contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. The Arduino Software (IDE): The Arduino Integrated Development Environment – or Arduino Software (IDE) A text editor for writing code A message area A text consoles A toolbar with buttons for common functions and a series of menus. Arduino IDE connects to the Arduino hardware to upload programs and communicate with them. Installation of Arduino Software (IDE) Download Arduino from: http://arduino.cc/en/Main/Software and proceed with the installation following the onscreen menus and by allowing the driver installation process. Arduino Sketch Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino Software (IDE), including complete error messages and other information. The bottom righthand corner of the window displays the configured board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor. Selecting Board and the Port Before a sketch can be verified and uploaded, it is required to select the right board and port from the Tools > Board and Tools > Port menus or Arduino IDE. Click on Tools in the menu bar and find the Port row. If a board is currently selected it will be displayed here. Hover over the Port to reveal all ports. For Arduino devices, the board name will typically be displayed after the port, for example: COM3 (Arduino Uno) On Windows, port is probably COM1 or COM2 (for a serial board) or COM4, COM5, COM7, or higher (for a USB board) – to find out, you look for USB serial device in the ports section of the Windows Device Manager. Compiling and Uploading the Sketch: It is a two step process. Click Verify (Compile) goto Sketck menu and click verify or press Ctrl-R Click Upload button on menu The progress of compilation and uploading will be shown in the bottom output window Arduino Program structure The sketch on the Arduino IDE is written using the C/C++ language. The IDE include added inbuilt-in functions which are helpful in writing the sketch. pinMode(), digitalWrite(), and digitalRead(), AnalogWrite(), AnalogRead and some of the built-in functions. Every Arduino sketch includes two functions- these are void setup() and void loop(). On top of the sketch is the place for the global declaration of variables and header files. A sample sketch is shown in the following figure. Arduino Sketch to sense LDR and ON-OFF and LED Summary: In this experiment we have learnt about the Arduino Uno platform, the pin diagram, mapping of Atmega and the Arduino pins, verify and uploading of the sketch on the board. Viva Questions What are different type of pins on an arduino board Which microcontroller is used on the Arduino Uno board Recall the mapping of the Arduino and Atmega-328 pins How will you select the right board and the ports from the Arduino IDE Share on Facebook Share Send email Mail Print Print