EMBEDDED SYSTEM DEVELOPMENT A SUMMER INTERN REPORT Submitted by VISHAL GARG Roll No: 03996402813 in partial fulfillmentof SummerInternship for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICSAND COMMUNICATION ENGINEERING Maharaja Agrasen Institute of Technology Guru Gobind Singh Indraprastha University, Delhi
2013-2017 TABLE OF CONTENTS Title Page ……(1) Certificate by the Supervisor ……(2) Acknowledgement ……(3) List of Figures ……(4) List of Tables ……(5) List of Photographs ……(6) ABSTRACT ……(7)
CHAPTER (1) INTRODUCTION 1.1 Aim of project 1.1 Outlin 1.3 Methodology CHAPTER(2) LITERATURE REVIEW 2.4 Embedded system CHAPTER (3)ARDUINO UNO 3.1 History 3.2 Development 3.3 libraries 3.4 Hardware 3.5 Software 3.6 Board and its pin 3.7 Microcontroller CHAPTER (4)PROGRAMING WITH ARDUINO UNO
4.1 Creating a program 4.2 Glowing LED’s in sequence 4.3 Digital temperature sensor interfacing using LCD 4.4 keypad interfacing 4.5GPS interfacing 4.6 RFID interfacing 4.7 Ultrasonic Sensors CHAPTER(5)APPLICATION OF ARDUINO UNO CHAPTER (6) RESULTS AND DISCUSSIONS CHAPTER(7) CONCLUSION CHAPTER(8) REFERENCES
LIST OF FIGURES SNO FIGURE NO FIGURE DESCRIPTION PAGE NO 1 1.1 ARDUINO BOARD 22 2 1.2 MICROCONTROLLER 26 3 1.3 GLOWING LED IN SEQUENCE 31 4 1.4 TEMPERATURE SENSOR USING LCD AND ATMEGA 35 5 1.5 TEMPERATURE SENSOR USING LCD AND ATMEGA 37 6 1.6 KEYPAD INTERFACING 43 7 1.7 ULTRASONIC SENSOR 49
LIST OF TABLES S.NO TABLE NO. DESCRIPTION PG.NO 1 1.1 PROPERTIES OF MICROCONTROLLER 22 2 1.2 COMPARISON OF MICROCONTROLLERS 27
LIST OF PHOTOGRAPHS S.NO. PHOTO. NO. DESCRIPTION PG. NO. 1 1.1 CREATORS OF ARDUINO 17 2 1.2 MY CUSTOM BOARD WITH OTHER MEMBERS 53
CERTIFICATE This is to certify that this project report entitled Embedded system development by VISHAL GARG(Roll no:03996402813) , submitted in partial fulfillment of the requirements for the degree of Bachelor of Technology in Electronics and Communication Engineering of the Maharaja Agrasen Institute of technology, Delhi, during the academic year 2015, is a bonafide record of work carried out under .The results embodied in this report have not been submitted to any other University or Institution for the award of any degree . date : ---------- --------- Teacher in charge Institution Rubber Stamp
ACKNOWLEDGEMENT I would like to express my sincere thanks to VMDD TECHNOLOGIES, for giving me the opportunity to carry out the Internship Program in their organization. I am very thankful to Mr. DEVANSHU SHUKLA (Project Guide), for giving me the opportunity to complete my training in VMDD TECHNOLOGIES and giving me the guidance and interest throughout the preparation of this project. I take this opportunity, also express my love and sincere thanks to my family members and friends for their support and advice during various stage of work. Last but not the least I thank God almighty for giving me the support for the completion of (Signature of the student)
ABSTRACT This is a report about Arduino board and programming environment. It contains basic working of Arduino , different types of Arduino boards, interfacing with Arduino programming environment, how to program, basic instructions regarding that and interfacing of a few sensors is shown in the content. Arduino is an open source platform that offers a clear and simple environment for physical computing. It is now widely used in modern robotics and Internet-of-Things applications, because of its low-cost, ease of programming, and rapid prototyping capabilities. We used the Arduino IDE to develop programs for the Arduino boards. For the computer interactive projects, we used a programming language called Processing.Sensors and actuators can easily be connected to the analog and digital I/O pins of an Arduino device, which features an on-board microcontroller programmed using the Arduino API.
CHAPTER 1 : INTRODUCTION 1.1 Aim of the project The aim of the project is to develop some understanding about what embedded system is and how we can design our own modules using Arduino uno. Apart from these it also provides knowledge about some software platform. 1.2 Outlines of Report This report contains a detailed information about all the components used in this project. The components used are: Arduino UNO Temperature sensor GPS module Ultrasonic sensor LCD LED Bluetooth module Keypad interfacing A detailed report about each and every component is described in separate chapter. Chapter 2 contains information about Embedded System. Chapter 3 contains information about Arduino uno. Chapter 4 contains information about Arduino software. Chapter 5 contains information about Programmming using Arduino. Chapter 6 contains Results and discussions.
1.3 Methodologies The idea of this project is to give information about the accident to the ambulance and family members, so we have chose GSM technology to give the information by sending SMS. Sending SMS alone can’t help the driver, if we send and an SMS saying that accident had occurred where the ambulance will come without knowing the location of the accident. So we include GPS location in the SMS which we are sending so that the ambulance will have perfect information about where and when the accident has occurred. For this we use GPS module to extract the location of the accident, the GPS data will contain the latitude and longitude values using which we can find the accurate position of the accident place. To run the GPS and GSM module we use Arduino UNO board which has ATmega328 microcontroller. The Arduino is a very user friendly device which can be easily interfaced with any sensors or modules and is very compact in size. Also we can make rfid card detector using Arduino UNO using which one can make detect his own RFID card if available like if one wants to check balance in metro card, attendance record in office, and many more. Finally we can sense the room temperature and distance of any object.One can also glow LED’s in some beautiful dancing patterns and display them on LCD. CHAPTER 2 : LITERATURE REVIEW
A literature review is collection of a critical, unbiased, and comprehensive evaluation of published information in a chosen and specific area of study of interest. It gives a general understanding of findings of the research work, conclusions, and recommendations and thereby brings out their strengths and weaknesses. This helps in identifying gaps, scope for further work and generalized concepts in the existing body of knowledge. Embedded System An embedded system is some combination of hardware and software, either fixed in capability or programmable, that is specifically designed for a particular function. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system. In embedded systems, software commonly known as firmware is hidden inside the same hardware rather than in some other hardware. Basically embedded systems are task specific devices. One of its most important characteristic is gives the output within the time constraints or you can say they are time bound systems. These embedded systems help to make the work more convenient and accurate. So, we often use these embedded systems in simple and complicated devices too. We use these embedded systems in our real life for many devices and applications such as Calculators, microwave, television remote control, home security and neighborhood traffic control systems, etc. Modern embedded systems are often based on microcontrollers (i.e. CPUs with integrated memory or peripheral interfaces) but ordinary microprocessors (using external chips for memory and peripheral interface circuits) are also still common, especially in more complex systems. In either case, the processor(s) used may be types ranging from general purpose to those specialized in certain class of
computations or even custom designed for the application at hand. A common standard class of dedicated processors is the digital signal processor (DSP). Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, and largely complex systems like hybrid vehicles, MRI, and avionics. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large or enclosure. Author Steve Heath There are many definitions for this but the best way to define it is to describe it in terms of what it is not and with examples of how it is used. An embedded system is a microprocessor-based system that is built to control a function or range of functions and is not designed to be programmed by the end user in the same way that a PC is. Yes, a user can make choices concerning functionality but cannot change the functionality of the system by adding/replacing software. With a PC, this is exactly what a user can do: one minute the PC is a word processor and the next it’s a games machine simply by changing the software. An embedded system is designed to perform one particular task albeit with choices and different options. The last point is important because it differentiates itself from the world of the PC where the end user does reprogram it whenever a different software package is bought and run. However, PCs have provided an easily accessible source of hardware and software for embedded systems and it should be no surprise that they form the basis of many embedded systems. To reflect this, a very detailed design example is included at the end of this book that uses a PC in this way to build a sophisticated data logging system for a race car. If this need to control the physical world is so great, what is so special about embedded systems that has led to the widespread use of microprocessors? There are several major reasons and these have increased over
the years as the technology has progressed and developed. Replacement for discrete logic-based circuits The microprocessor came about almost by accident
ARDUINO UNO ARDUINO is an open source computer hardware and software company, project and user community that designs and manufactures microcontroller based kits for building digital devices and interactive objects that can sense and control the physical world. The project is based on a family of microcontroller board designs manufactured primarily by SmartProjects in Italy, and also by several other vendors, using various 8-bit atmel avr analog Input output pins that can be interfaced to various expansion boards ("shields") and other circuits. The boards feature serial communications interfaces, including usb on some models, for loading programs from personal computers. For programming the microcontrollers, the Arduino platform provides an integrated development environment (IDE) based on the Processing project, which includes support for C,C++ and java programming languages. The first Arduino was introduced in 2005, aiming to provide an inexpensive and easy way for novices and professionals to create devices that interact with their environment using sensors and actuators. Common examples of such devices intended for beginner hobbyists include simple robots, thermostats, and motion detectors. Arduino boards are available commercially in preassembled form, or as do-it-yourself kits. The hardware design specifications are openly available, allowing the Arduino boards to be manufactured by anyone. Adafruit Industries estimated in mid-2011 that over 300,000 official Arduinos had been commercially produced, and in 2013 that 700,000 official boards were in users' hands The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to- serial converter.: "Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions..
HISTORY OF ARDUINO Arduino started in 2005 as a project for students at the Interaction design institute in Ivrea, Italy. At that time program students used a "BASIC Stamp" at a cost of $100, considered expensive for students. Massimo Banzi, one of the founders, taught at Ivrea, The name "Arduino" comes from a bar in Ivrea, where some of the founders of the project used to meet. The bar, in turn, has been named after Arduin of Ivrea, who was the margrave of Ivrea and king of Italy from 1002 to 1014.Colombian student Hernando Barragan created the Wiring development platform which served as the basis for Arduino. Following the completion of the Wiring platform, its lighter, less expensive versions were created and made available to the open-source community; associated researchers, including David Cuartielles, promoted the idea. The Arduino's initial core team consisted of Massimo Banzi, David Cuartielles, Tom Ignore, Gianluca Martino, and David Mellis
DEVELOPMENT Arduino is open-source hardware: the Arduino hardware reference designs are distributed under a Creative Commons Attribution Share-Alike 2.5 license and are available on the Arduino Web site. Layout and production files for some versions of the Arduino hardware are also available. The source code for the IDE is available and released under the GNU General Public License, version 2. Although the hardware and software designs are freely available under copyleft licenses, the developers have requested that the name "Arduino" be exclusive to the official product and not be used for derivative works without permission. The official policy document on the use of the Arduino name emphasizes that the project is open to incorporating work by others into the official product. Several Arduino-compatible products commercially released have avoided the "Arduino" name by using "-duino" name variants.
LIBRARIES To use an existing library in a sketch, go to the Sketch menu, choose "Import Library", and pick from the libraries available. This will insert one or more #include statements at the top of the sketch and allow it to use the library. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its #include statements from the top of your code. These are the "official" libraries that are included in the Arduino distribution. EEPROM - reading and writing to "permanent" storage SoftwareSerial - for serial communication on any digital pins Stepper - for controlling stepper motors Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors. These libraries are compatible Wiring versions, and the links below point to the (excellent) Wiring documentation. Matrix - Basic LED Matrix display manipulation library Sprite - Basic image sprite manipulation library for use in animations with an LED matrix Contributed Libraries Libraries written by members of the Arduino community. DateTime - a library for keeping track of the current date and time in software. Firmata - for communicating with applications on the computer using a standard serial protocol. GLCD - graphics routines for LCD based on the KS0108 or equivalent chipset. LCD - control LCDs (using 8 data lines) LCD 4 Bit - control LCDs (using 4 data lines) LedControl - for controlling LED matrices or seven-segment displays with a MAX7221 or MAX7219. LedControl - an alternative to the Matrix library for driving multiple LEDs with Maxim chips. TextString - handle strings Metro - help you time actions at regular intervals MsTimer2 - uses the timer 2 interrupt to trigger an action every N milliseconds. OneWire - control devices (from Dallas Semiconductor) that use the One Wire protocol. PS2Keyboard - read characters from a PS2 keyboard. Servo - provides software support for Servo motors on any pins. Servotimer1 - provides hardware support for Servo motors on pins 9 and 10 Simple Message System - send messages between Arduino and the computer SSerial2Mobile - send text messages or emails using a cell phone (via AT commands over software serial) X10 - Sending X10 signals over AC power lines To install, unzip the library to a sub-directory of the hardware/libraries sub-directory of the Arduino application directory. Then launch the Arduino environment; you should see the library in the Import Library menu.
HARDWARE An Arduino board consists of an Atmel 8-, 16- or 32-bit AVR microcontroller with complementary components that facilitate programming and incorporation into other circuits. An important aspect of the Arduino is its standard connectors, which lets users connect the CPU board to a variety of interchangeable add-on modules known as shields. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an I²CAn Arduino board consists of an Atmel 8-, 16- or 32-bit AVR microcontroller with complementary components that facilitate programming and incorporation into other circuits. An important aspect of the Arduino is its standard connectors, which lets users connect the CPU board to a variety of interchangeable add-on modules known as shields. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an I²C serial bus—so many shields can be stacked and used in parallel. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, andATmega2560. A handful of other processors have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs such as the LilyPad run at 8 MHz and dispense with the onboard voltage regulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an external programmer. This makes using an Arduino more default bootloader installed on Arduino UNO. At a conceptual level, when using the Arduino software stack, all boards are programmed over an RS-232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino boards contain a level shifter circuit to convert between RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB, implemented using USB-to-seriaadapter chips such as the FTDIFT232. Some boards, such as later-model Unos, substitute the FTDI chip with a separate AVR chip containing USB-to-serial firmware (itself reprogrammable via its own ICSP header). Other variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools instead of the ArduinoIDE, standard AVR ISP programming is used.) The Arduino board exposes most of the microcontroller's I/O pins for use by other circuits. The current Uno provide 14 digital I/O pins, six of which can produce pulse-width modulated signals, and six analog inputs, which can also be used as six digital I/O pins. These pins are on the top of the board, via female 0.10-inch (2.5 mm) headers. Several plug-in application shields are also commercially available. The Arduino Nano, and Arduino-compatible Bare Bones Board and
Boarduino boards may provide male header pins on the underside of the board that can plug into solderless breadboards. There are many Arduino-compatible and Arduino-derived boards. Some are functionally equivalent to an Arduino and can be used interchangeably. Many enhance the basic Arduino by adding output drivers, often for use in school-level education to simplify the construction of buggies and small robots. Others are electrically equivalent but change the form factor, sometimes retaining compatibility with shields, sometimes not. Some variants use completely different processors, with varying levels of compatibility.serial bus—so many shields can be stacked and used in parallel. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, andATmega2560. A handful of other processors have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs run at 8 MHz and dispense with the onboard voltageregulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an externalprogrammer. This makes using an Arduino more straightforward by allowing the use of an ordinary computer as the programmer. Currently, optiboot bootloader is the default bootloader installed on Arduino UNO. At a conceptual level, when using the Arduino software stack, all boards are programed over an RS- 232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino boards contain a level shifter circuit to convert between RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB, implemented using USB-to-serial adapter chips such as the FTDIFT232. Some boards, such as later-model Unos, substitute the FTDI chip with a separate AVR chip containing USB-to-serial firmware (itself reprogrammable via its own ICSP header). Other variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools instead of the ArduinoIDE, standard AVR ISP programming is used.)equivalent to an Arduino and can be used interchangeably. Many enhance the basic Arduino by adding output drivers, often for use in school-level education to simplify the construction of buggies and small robots. Others are electrically equivalent but change the form factor, sometimes retaining compatibility with shields, sometimes not. Some variants use completely different processors, with varying levels of compatibility.
SOFTWARE The Arduino integrated development environment (IDE) is a cross-platform application written in Java, and derives from the IDE for the Processing programming language and the Wiring projects. It is designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling and uploading programs to the board with a single click. A program or code written for Arduino is called a "sketch". Arduino programs are written in C or C++. The Arduino IDE comes with a software library called "Wiring" from the original Wiring project, which makes many common input/output operations much easier. The users need only to define two functions to make an executable cyclic executive program: • setup(): a function that runs once at the start of a program and that can initialize settings. • loop(): a function called repeatedly until the board powers off. Most Arduino boards contain an LED and a load resistor connected between the pin 13 and ground, which is a convenient feature for many simple tests. The previous code would not be seen by a standard C++ compiler as a valid program, so when the user clicks the "Upload to I/O board" button in the IDE, a copy of the code is written to a temporary file with an extra include header at the top and a very simple main() function at the bottom, to make it a valid C++ program. The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs, and uses avr to upload programs to the board. As the Arduino platform uses Atmel microcontrollers, Atmel's development environment, AVR Studio or the newer Atmel Studio, may also be used to develop software for the Arduino.
ARDUINO BOARD Looking at the board from the top down, this is an outline of what you will see (parts of the board you might interact with in the course of normal use are highlighted): • Pins 2-13 (green) • Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o (digitalRead and digitalWrite) if you are also using serial communication (e.g. Serial.begin). • Reset Button - S1 (dark blue) • In-circuit Serial Programmer (blue-green) • Analog In Pins 0-5 (light blue) • Power and Ground Pins (power: orange, grounds: light orange) • External Power Supply In (9-12VDC) - X1 (pink) Toggles External Power and USB Power (place jumper on two pins closest to Starting clockwise from the top center: • Analog Reference pin (orange) • Digital Ground (light green) • Digital desired supply) - SV1 (purple) • USB (used for uploading sketches to the board and for serial communication between the board and the computer; can be used to power the board) (yellow)
DIGITAL PINS In addition to the specific functions listed below, the digital pins on an Arduino board can be used for general purpose input and output via the pinMode(), digitalRead(), and digitalWrite()commands. Each pin has an internal pull-up resistor which can be turned on and off using digitalWrite() (w/ a value of HIGH or LOW, respectively) when the pin is configured as an input. The maximum current per pin is 40 mA. • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. • 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 attachInterrupt() function for details. • PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function. On boards with an ATmega8, PWM output is available only on pins 9, 10, and 11. • BT Reset: 7. (Arduino BT-only) Connected to the reset line of the bluetooth module. • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language. • LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
ANALOG PINS In addition to the specific functions listed below, the analog input pins support 10-bit analog-to- digital conversion (ADC) using the analogRead() function. Most of the analog inputs can also be used as digital pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as digital pins. • I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library (documentation on the Wiring website). POWER PINS • VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. Note that different boards accept different input voltages ranges, please see the documentation for your board. Also note that the LilyPad has no VIN pin and accepts only a regulated input. • 5V. The regulated power supply used to power the microcontroller and other components on the board. This can come either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V supply. • 3V3. (Diecimila-only) A 3.3 volt supply generated by the on-board FTDI chip. • GND. Ground pins. • AREF. Reference voltage for the analog inputs. Used with analogReference(). • Reset. (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board..
Microcontrollers Microcontroller ATmega328P Operating Voltage 5V Input Voltage (recommended) 7-12 V Input Voltage (limit) 6-20 V Digital I/O Pins 14 (of which 6 provide PWM Output) PWM Digital I/O Pins 6 Analog Input Pins 6 DC Current per I/O pin 20 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB (ATmega 328P) of which 0.5 KB used by bootloader SRAM 2 KB (ATmega 328P)
EEPROM 1 KB (ATmega328P) Clock Speed 16 MHz Length 68.6 mm Width 53.4 mm Weight 25 g MEMORYSUMMARY DEVICE FLASH EEPROM RAM INTERRUPT SIZE ATmega48PA 4K Bytes 256 Bytes 512 Bytes 1 instruction word/vector ATmega88PA 8K Bytes 512 Bytes 1K Bytes 1 instruction word/vector ATmega168PA 16K Bytes 512 Bytes 1K Bytes 2 instruction word/vector ATmega328P 32K Bytes 1K Bytes 2K Bytes 2 instruction word/vector
PROGRAMMING WITH ARDUINO The Arduino runs on a simplified version of the C programming language, with some extensions for accessing the hardware. In this guide, we will cover the subset of the programming language that is most useful to the novice Arduino designer. All Arduino instructions are one line. The board can hold a program hundreds of lines long and has space for about 1,000 two-byte variables. The Arduino executes programs at about 300,000 source code lines per sec. 4.1Creating a Program Programs are created in the Arduino development environment and then downloaded to the Arduino board. Code must be entered in the proper syntax which means using valid command names and a valid grammar for each code line. The compiler will catch and flag syntax errors before download. Sometimes the error message can be cryptic and you have to do a bit of hunting because the actual error occurred before what was flagged. Although your program may pass cleanly through the syntax checker, it still might not do what you wanted it to. Here is where you have to hone your skills at code debugging. The Arduino did what you told it to do rather than what you wanted it to do. The best way to catch these errors is to read the code line by line and be the computer. Having another person go through your code also helps. Skilled debugging takes practice. Program Formatting and Syntax Programs are entered line by line. Code is case sensitive which means "myvariable" is different than "MyVariable". Statements are any command. Statements are terminated with a semi-colon. A classic mistake is to forget the semi-colon so if your program does not compile, examine the error text and see if you forgot to enter a colon. Comments are any text that follows “//” on a line. For multi-line block comments, begin with “/*” and end with “*/”
CONSTANT Constants are fixed numbers and can be entered as ordinary decimal numbers (integer only) or in hexadecimal (base 16) or in binary (base 2) as shown in the table below Decimal Hex Binary 17 100 0x64 B01100100 LABEL Labels are used to reference locations in your program. They can be any combination of letters, numbers and underscore (_), but the first character must be a letter. When used to mark a location, follow the label with a colon. When referring to an address label in an instruction line, don't use the colon. Here's an example repeat: digitalWrite(2,HIGH); delay(1000); digitalWrite(2,LOW); delay(1000); goto repeat; Use labels sparingly as they can actually make a program difficult to follow and challenging to debug. In fact, some C programmers will tell you to never use labels. VARIABLES Variables are allocated by declaring them in the program. Every variable must be declared. If a variable is declared outside the braces of a function, it can be seen everywhere in the program. If it is declared inside the braces of a function, the variable can only be seen within that function. Variables come in several flavors including byte (8-bit, unsigned, 0 to 255), word (16-bit, unsigned, 0 to 65,536), int (16-bit, signed, -32,768 to 32,767), and long (32-bit, signed, -2,147,483,648 to 2,147,483,647). Use byte variables unless you need negative numbers or numbers larger than 255, then use int variables. Using larger sizes than needed fills up precious memory space. Variable declarations generally appear at the top of the program byte i; word k; int length; int width; Variable names can be any combination of letters and numbers but must start with a letter. Names reserved for programming instructions cannot be used for variable names and will give you an error message
Simple Commands This section covers the small set of commands you need to make the Arduino do something useful. These commands appear in order of priority. You can make a great machine using only digital read, digital write and delay commands. Learning all the commands here will take you to the next level. PinMode This command, which goes in the setup() function, is used to set the direction of a digital I/O pin. Set the pin to OUTPUT if the pin is driving and LED, motor or other device. Set the pin to INPUT if the pin is reading a switch or other sensor. On power up or reset, all pins default to inputs. The Serial.print command Used to print data serially. For the command to work, the command Serial.begin(9600) must be placed in the setup() function. After the program is uploaded, you must open the Serial Monitor window to see the response. There are two forms of the print command. Serial.print() prints on the same line while Serial.println() starts the print on a new line.
PROGRAMS 4.2 Glowing LED’s in sequence This program glows Led’s in sequence according to character typed from keyboard and also display that character on LCD screen. Code #include<LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); int thisPin; void setup() { lcd.begin(16,2); Serial.begin(9600); Serial.println("-----------Main Menu--------------"); Serial.println("Press a for LED1"); Serial.println("Press b for LED2"); Serial.println("Press c for LED3"); Serial.println("Press d for LED4"); Serial.println("Press e for LED5"); Serial.println("press any key to switch off the LED"); Serial.println("-------------------------------------"); for( thisPin=2;thisPin<7;thisPin++);
{ pinMode(thisPin,OUTPUT); } } void loop() { if(Serial.available()>0) { char rx=Serial.read(); switch(rx) { case 'a': Serial.println("LED1 is ON"); lcd.setCursor(0,1); lcd.print("LED1"); digitalWrite(2,HIGH); break; case 'b': Serial.println("LED2 is ON"); lcd.setCursor(5,1); lcd.print("LED2"); digitalWrite(3,HIGH); break; case 'c': Serial.println("LED3 is ON"); lcd.setCursor(11,1); lcd.print("LED3"); digitalWrite(4,HIGH); break; case 'd': Serial.println("LED4 is ON"); lcd.setCursor(0,2); lcd.print("LED4"); digitalWrite(5,HIGH); break; case 'e':
Serial.println("LED5 is ON"); lcd.setCursor(8,2); lcd.print("LED5"); digitalWrite(6,HIGH); break; default: for(int thisPin=2;thisPin<7;thisPin++) { digitalWrite(thisPin,LOW); } Serial.println("All LEDs are off"); lcd.clear(); } } }
4.3 DIGITAL TEMPERATURESENSOR INTERFACINGUSING LCD Components Required: 1 ) Developments board. 2) 2*16 LCD 3) Digital Temperature Sensor 4) Pot-Meter (10k) 5) Resistor 560 ohm 6) Bread Board 7) Couple of Jumper Wire Temperature Sensor - Waterproof (DS18B20) Description: This sealed digital temperature probe lets you precisely measure temperatures in wet environments with a simple 1-Wire interface. The DS18B20 provides 9 to 12-bit (configurable) temperature readings over a 1-Wire interface,so that only one wire (and ground) needs to be connected from a central microprocessor. What is 2*16 LCD • LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. • A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data. Circuit Connection of Temperature Sensors Using LCD and Atmega
Code : #include<OneWire.h> #include<DallasTemperature.h> #include<LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); #define singleWire 6 OneWire ourWire(singleWire); DallasTemperature sensors(&ourWire); void setup() { Serial.begin(9600); Serial.print("Temperature value"); lcd.begin(16,2); lcd.print("***Temperature***"); sensors.begin(); } void loop() { sensors.requestTemperatures(); Serial.print(sensors.getTempCByIndex(0)); Serial.println(" C");
lcd.setCursor(0,1); lcd.print(sensors.getTempCByIndex(0)); lcd.print(" C,"); Serial.print(sensors.getTempFByIndex(0)); Serial.println(" F"); lcd.setCursor(8,1); lcd.print(sensors.getTempFByIndex(0)); lcd.print(" F"); }
4.4 KEYPAD INTERFACING Components Required: 1.) Custom Board 2.) LED RED 3.) LED GREEN 4.) POT-METER(10k) 5.) 2 x 16 LCD 6.) Breadboard 7.) Resistor 560 ohm 8.) Couple of Jumper Wire 9.) Hex-Keypad Interfacing hex keypad to Atmega-328p This article is about how to interface a hex keypad to Atmega-328. Hex keypad is a very important component in embedded systems and the typical applications are code locks, calculators, automation systems or simply any thing that requires a character or numeric input. Hex keypad. Hex key pad is simply an arrangement 0f 16 push button switches in a 4X4 matrix form. Typically a hex keypad will have keys for number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and letters A, B, C, D, *, #. The hex keypad will have 8 connection wires namely R1, R2, R3, R4 and C1, C2, C3, C4 representing the rows and columns respectively. The schematic diagram and photo of a typical hex keypad is shown in the figure below. Code :
#include<Password.h> #include<Keypad.h> #include<LiquidCrystal.h> Password password=Password("1#3*5"); int len=5;//size of password int ledRed=11;//for Wrong int ledGreen=12;//for Success int ilosc;//number of clicks LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); const byte ROWS=4; const byte COLS=4; char keys[ROWS][COLS]={ {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS]={5,4,3,2}; byte colPins[COLS]={9,8,7,6}; Keypad keypad=Keypad(makeKeymap(keys),rowPins,colPins,ROWS,COLS); void setup() { keypad.addEventListener(keypadEvent); Serial.begin(9600); pinMode(ledRed,OUTPUT); pinMode(ledGreen,OUTPUT); lcd.begin(16,2); lcd.setCursor(1,0); lcd.print("PLEASE ENTER PIN"); } void loop() { keypad.getKey(); } void keypadEvent(KeypadEvent eKey) {
switch(keypad.getState()) { case PRESSED: Serial.print("pressed: "); Serial.println(eKey); } Serial.println(ilosc); if(ilosc == 1) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("*_"); } if(ilosc == 2) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("**_"); } if(ilosc == 3) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("***_"); } if(ilosc==4) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> ");
lcd.setCursor(0,1); lcd.print("****_"); } if(ilosc==5) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("*****_"); } if(ilosc == len) { delay(250); checkPassword(); ilosc=0; } } void checkPassword() { if(password.evaluate()) { ilosc = 0; Serial.println("Success"); digitalWrite(ledRed,LOW); digitalWrite(ledGreen,HIGH); lcd.clear(); lcd.setCursor(0,1); lcd.print("<<SUCCESS>>"); } else { ilosc = 0; password.reset(); Serial.println("Wrong"); digitalWrite(ledGreen,LOW);
lcd.clear(); lcd.setCursor(1,0); lcd.print(" :WELCOME:"); lcd.setCursor(0,1); lcd.print("PLEASE ENTER PIN"); } }
4.5 GPS INTERFACING Components Required: 1.) Custom Board 2.) POT-METER(10k) 3.) 2 x 16 LCD 4.) Breadboard 5.) Resistor 560 ohm 6.) Couple of Jumper Wire 7.) Ublox GPS Module What is GPS? The Global Positioning System (GPS) is a satellite-based navigation system made up of a network of 24 satellites placed into orbit by the U.S. Department of Defense. GPS was originally intended for military applications, but in the 1980s, the government made the system available for civilian use. GPS works in any weather conditions, anywhere in the world, 24 hours a day. There are no subscription fees or setup charges to use GPS. How Does GPS Work: The GPS system currently has 31 active satellites in orbits inclined 55 degrees to the equator. The satellites orbit about 20,000km from the earth's surface and make two orbits per day.The orbits are designed so that there are always 6 satellites in view, from most places on the earth. The GPS receiver can determine your position in three dimensions - east, north and altitude. GPS Receiver: GPS Receiver received the information in string format, transmitted by Satellites, which uses this information to calculate different parameters between it and satellites. With information from satellites, a GPS receiver can fix it location on the ground from the known position of the satellites. Now I want to drag your attention on the purpose of this project. In this project, we are going to display ‘Latitude & Longitude’ used for positioning of an object on the earth. So let’s talk about how a GPS receiver fixes its location on the ground, as i above said and the find the location of an object on the earth. Pin Configuration of U-Blox GPS: 1.VCC: +5v Power Supply 2.TX : Data Transmission 3.RX : Data Receiver 4.GND: Ground
Code : #include<TinyGPS.h> #include<SoftwareSerial.h> long lat,lon; TinyGPS gps; SoftwareSerial gpsSerial(3,4); void setup() { Serial.begin(9600); gpsSerial.begin(9600); } void loop() { while(gpsSerial.available()) { if(gps.encode(gpsSerial.read())) { gps.get_position(&lat,&lon);
Serial.print("Receive GPS signal is:"); Serial.println("Position:"); Serial.print("Longitude:"); Serial.print(lon); Serial.print(" "); Serial.print("Latitude:"); Serial.print(lat); } } }
4.6 RFID INTERFACING Code : //add libraries to your project #include<AddicoreRFID.h> #include<LiquidCrystal.h> #include<SPI.h> #define uchar unsigned char #define uint unsigned int //class to include functions of rfid AddicoreRFID myRFID; int chipSelectPin=10; #define MAX_LEN 16 void setup(){ //led lcd.begin(16,2); lcd.println("RFID World"); pinMode(6,OUTPUT); //convert binary to human readable form SPI.begin(); //initialise or activate rfid //as setup execute only once digitalWrite(6,LOW); //initialise the rfid myRFID.AddicoreRFID_Init(); } unsigned char structure[16]; unsigned char status; void loop(){ uchar status; uchar str[MAX_LEN]; status=myRFID.AddicoreRFID_Request(PICC_REQIDL,str); status=myRFIDAddicoreRFID_Anticoll(str); if(status==MI_OK){ lcd.setCursor(0,1); lcd.print("Tag ID:"); lcd.setCursor(8,1);
lcd.print(str[0]); digitalWrite(6,HIGH); delay(1000); digitalWrite(6,LOW); } myRFID.AddicoreRFID_Halt(); }
4.7 ULTRASONIC SENSOR Components Required: 1.) Custom Board 2.) POT-METER(10k) 3.) 2 x 16 LCD 4.) Breadboard 5.) Resistor 560 ohm 6.) Couple of Jumper Wire 7.) HC-SR04 Interfacing of ultrasonic Sensors withAtmega-328p HC-SR04 Ultrasonic distance sensors is a popular and low cost solution for non-contact distance measurement function. It is able to measure distances from 1cm to 400cm with an accuracy of about 3mm. This module includes ultrasonic transmitter, ultrasonic receiver and its control circuit. HC-SR04 module has 4 pins : VCC – 5V power supply TRIG – Trigger Pin ECHO – Echo Pin GND – Ground power supply
Code : #include<LiquidCrystal.h> LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); const int trigPin=2; const int echoPin=4; void setup() { lcd.begin(16,2); Serial.begin(9600); Serial.print("Distance Between Object and Sensors"); } void loop() { long inches,cm,duration; pinMode(trigPin,OUTPUT); digitalWrite(trigPin,LOW); delayMicroseconds(2); digitalWrite(trigPin,HIGH); delayMicroseconds(10);
digitalWrite(trigPin,LOW); pinMode(echoPin,INPUT); duration=pulseIn(echoPin,HIGH);//time inches=microsecondsToInches(duration); cm=microsecondsToCentimeter(duration); lcd.clear(); lcd.print("Distance Finder:"); lcd.setCursor(0,1); lcd.print("INCHES"); lcd.setCursor(7,1); lcd.print(inches); Serial.print("INCHES"); lcd.setCursor(10,1); lcd.print("CM:"); lcd.setCursor(13,1); lcd.print(cm); Serial.print(cm); Serial.println("centimeter"); } long microsecondsToInches(long microseconds) { return microseconds /74/2; } long microsecondsToCentimeter(long microseconds) { return microseconds /29/2; }
CHAPTER 6 : RESULTS AND DISCUSSIONS 6.1 Results and Conclusions Over the years,Arduino has went out to become a huge success and a common name among students.With google deploying it,people’s imagination has went out to much higher level than before.A developer in the annual GOOGLE IO conference said “when Arduino and Android coming together,this really proves “INFINITY EXISTS” in the future”.I think a study on arduino and practical experiments on arduino must be added for UG courses of engineering,to help students to leverage their talents,and imagination.
CONCLUSION Arduino in conjunction with participatory design and interactive design yields successful results. Once users are knowledgeable of the Arduino programming language they are able to implement a variety of solutions to numerous problems.Tangible and graphical programming languages have been proven to be successful in stimulating and educating programmers. Both have been found to make an improvement in learning when used with participatory and interactive design. In terms of learning how to program, tangible programming has shown better results. Thus, there is an opportunity to develop a tangible or graphical programming language for Arduino. Possibly a combination of the two along with adopting participatory and interactive design practices could yield an improved Arduino programming language that all of its users can use with ease and creativity. Focussing on how the users want to program and not how they should theoretically be programming.
REFERENCES 1.http://www.arduino.cc -Arduino official webpage 2.http://en.wikipedia.org/wiki/Arduino -wikipedia 3.http://www.instructables.com 4.http://www.adafruit.com 5.http://www.electroschematics.com
ARDUINO EMBEDDED SYSTEM

ARDUINO EMBEDDED SYSTEM

  • 1.
    EMBEDDED SYSTEM DEVELOPMENT ASUMMER INTERN REPORT Submitted by VISHAL GARG Roll No: 03996402813 in partial fulfillmentof SummerInternship for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICSAND COMMUNICATION ENGINEERING Maharaja Agrasen Institute of Technology Guru Gobind Singh Indraprastha University, Delhi
  • 2.
    2013-2017 TABLE OF CONTENTS TitlePage ……(1) Certificate by the Supervisor ……(2) Acknowledgement ……(3) List of Figures ……(4) List of Tables ……(5) List of Photographs ……(6) ABSTRACT ……(7)
  • 3.
    CHAPTER (1) INTRODUCTION 1.1 Aimof project 1.1 Outlin 1.3 Methodology CHAPTER(2) LITERATURE REVIEW 2.4 Embedded system CHAPTER (3)ARDUINO UNO 3.1 History 3.2 Development 3.3 libraries 3.4 Hardware 3.5 Software 3.6 Board and its pin 3.7 Microcontroller CHAPTER (4)PROGRAMING WITH ARDUINO UNO
  • 4.
    4.1 Creating aprogram 4.2 Glowing LED’s in sequence 4.3 Digital temperature sensor interfacing using LCD 4.4 keypad interfacing 4.5GPS interfacing 4.6 RFID interfacing 4.7 Ultrasonic Sensors CHAPTER(5)APPLICATION OF ARDUINO UNO CHAPTER (6) RESULTS AND DISCUSSIONS CHAPTER(7) CONCLUSION CHAPTER(8) REFERENCES
  • 5.
    LIST OF FIGURES SNOFIGURE NO FIGURE DESCRIPTION PAGE NO 1 1.1 ARDUINO BOARD 22 2 1.2 MICROCONTROLLER 26 3 1.3 GLOWING LED IN SEQUENCE 31 4 1.4 TEMPERATURE SENSOR USING LCD AND ATMEGA 35 5 1.5 TEMPERATURE SENSOR USING LCD AND ATMEGA 37 6 1.6 KEYPAD INTERFACING 43 7 1.7 ULTRASONIC SENSOR 49
  • 6.
    LIST OF TABLES S.NOTABLE NO. DESCRIPTION PG.NO 1 1.1 PROPERTIES OF MICROCONTROLLER 22 2 1.2 COMPARISON OF MICROCONTROLLERS 27
  • 7.
    LIST OF PHOTOGRAPHS S.NO.PHOTO. NO. DESCRIPTION PG. NO. 1 1.1 CREATORS OF ARDUINO 17 2 1.2 MY CUSTOM BOARD WITH OTHER MEMBERS 53
  • 8.
    CERTIFICATE This is tocertify that this project report entitled Embedded system development by VISHAL GARG(Roll no:03996402813) , submitted in partial fulfillment of the requirements for the degree of Bachelor of Technology in Electronics and Communication Engineering of the Maharaja Agrasen Institute of technology, Delhi, during the academic year 2015, is a bonafide record of work carried out under .The results embodied in this report have not been submitted to any other University or Institution for the award of any degree . date : ---------- --------- Teacher in charge Institution Rubber Stamp
  • 9.
    ACKNOWLEDGEMENT I would liketo express my sincere thanks to VMDD TECHNOLOGIES, for giving me the opportunity to carry out the Internship Program in their organization. I am very thankful to Mr. DEVANSHU SHUKLA (Project Guide), for giving me the opportunity to complete my training in VMDD TECHNOLOGIES and giving me the guidance and interest throughout the preparation of this project. I take this opportunity, also express my love and sincere thanks to my family members and friends for their support and advice during various stage of work. Last but not the least I thank God almighty for giving me the support for the completion of (Signature of the student)
  • 10.
    ABSTRACT This is areport about Arduino board and programming environment. It contains basic working of Arduino , different types of Arduino boards, interfacing with Arduino programming environment, how to program, basic instructions regarding that and interfacing of a few sensors is shown in the content. Arduino is an open source platform that offers a clear and simple environment for physical computing. It is now widely used in modern robotics and Internet-of-Things applications, because of its low-cost, ease of programming, and rapid prototyping capabilities. We used the Arduino IDE to develop programs for the Arduino boards. For the computer interactive projects, we used a programming language called Processing.Sensors and actuators can easily be connected to the analog and digital I/O pins of an Arduino device, which features an on-board microcontroller programmed using the Arduino API.
  • 11.
    CHAPTER 1 :INTRODUCTION 1.1 Aim of the project The aim of the project is to develop some understanding about what embedded system is and how we can design our own modules using Arduino uno. Apart from these it also provides knowledge about some software platform. 1.2 Outlines of Report This report contains a detailed information about all the components used in this project. The components used are: Arduino UNO Temperature sensor GPS module Ultrasonic sensor LCD LED Bluetooth module Keypad interfacing A detailed report about each and every component is described in separate chapter. Chapter 2 contains information about Embedded System. Chapter 3 contains information about Arduino uno. Chapter 4 contains information about Arduino software. Chapter 5 contains information about Programmming using Arduino. Chapter 6 contains Results and discussions.
  • 12.
    1.3 Methodologies The ideaof this project is to give information about the accident to the ambulance and family members, so we have chose GSM technology to give the information by sending SMS. Sending SMS alone can’t help the driver, if we send and an SMS saying that accident had occurred where the ambulance will come without knowing the location of the accident. So we include GPS location in the SMS which we are sending so that the ambulance will have perfect information about where and when the accident has occurred. For this we use GPS module to extract the location of the accident, the GPS data will contain the latitude and longitude values using which we can find the accurate position of the accident place. To run the GPS and GSM module we use Arduino UNO board which has ATmega328 microcontroller. The Arduino is a very user friendly device which can be easily interfaced with any sensors or modules and is very compact in size. Also we can make rfid card detector using Arduino UNO using which one can make detect his own RFID card if available like if one wants to check balance in metro card, attendance record in office, and many more. Finally we can sense the room temperature and distance of any object.One can also glow LED’s in some beautiful dancing patterns and display them on LCD. CHAPTER 2 : LITERATURE REVIEW
  • 13.
    A literature reviewis collection of a critical, unbiased, and comprehensive evaluation of published information in a chosen and specific area of study of interest. It gives a general understanding of findings of the research work, conclusions, and recommendations and thereby brings out their strengths and weaknesses. This helps in identifying gaps, scope for further work and generalized concepts in the existing body of knowledge. Embedded System An embedded system is some combination of hardware and software, either fixed in capability or programmable, that is specifically designed for a particular function. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system. In embedded systems, software commonly known as firmware is hidden inside the same hardware rather than in some other hardware. Basically embedded systems are task specific devices. One of its most important characteristic is gives the output within the time constraints or you can say they are time bound systems. These embedded systems help to make the work more convenient and accurate. So, we often use these embedded systems in simple and complicated devices too. We use these embedded systems in our real life for many devices and applications such as Calculators, microwave, television remote control, home security and neighborhood traffic control systems, etc. Modern embedded systems are often based on microcontrollers (i.e. CPUs with integrated memory or peripheral interfaces) but ordinary microprocessors (using external chips for memory and peripheral interface circuits) are also still common, especially in more complex systems. In either case, the processor(s) used may be types ranging from general purpose to those specialized in certain class of
  • 14.
    computations or evencustom designed for the application at hand. A common standard class of dedicated processors is the digital signal processor (DSP). Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale. Embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, and largely complex systems like hybrid vehicles, MRI, and avionics. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large or enclosure. Author Steve Heath There are many definitions for this but the best way to define it is to describe it in terms of what it is not and with examples of how it is used. An embedded system is a microprocessor-based system that is built to control a function or range of functions and is not designed to be programmed by the end user in the same way that a PC is. Yes, a user can make choices concerning functionality but cannot change the functionality of the system by adding/replacing software. With a PC, this is exactly what a user can do: one minute the PC is a word processor and the next it’s a games machine simply by changing the software. An embedded system is designed to perform one particular task albeit with choices and different options. The last point is important because it differentiates itself from the world of the PC where the end user does reprogram it whenever a different software package is bought and run. However, PCs have provided an easily accessible source of hardware and software for embedded systems and it should be no surprise that they form the basis of many embedded systems. To reflect this, a very detailed design example is included at the end of this book that uses a PC in this way to build a sophisticated data logging system for a race car. If this need to control the physical world is so great, what is so special about embedded systems that has led to the widespread use of microprocessors? There are several major reasons and these have increased over
  • 15.
    the years asthe technology has progressed and developed. Replacement for discrete logic-based circuits The microprocessor came about almost by accident
  • 16.
    ARDUINO UNO ARDUINO isan open source computer hardware and software company, project and user community that designs and manufactures microcontroller based kits for building digital devices and interactive objects that can sense and control the physical world. The project is based on a family of microcontroller board designs manufactured primarily by SmartProjects in Italy, and also by several other vendors, using various 8-bit atmel avr analog Input output pins that can be interfaced to various expansion boards ("shields") and other circuits. The boards feature serial communications interfaces, including usb on some models, for loading programs from personal computers. For programming the microcontrollers, the Arduino platform provides an integrated development environment (IDE) based on the Processing project, which includes support for C,C++ and java programming languages. The first Arduino was introduced in 2005, aiming to provide an inexpensive and easy way for novices and professionals to create devices that interact with their environment using sensors and actuators. Common examples of such devices intended for beginner hobbyists include simple robots, thermostats, and motion detectors. Arduino boards are available commercially in preassembled form, or as do-it-yourself kits. The hardware design specifications are openly available, allowing the Arduino boards to be manufactured by anyone. Adafruit Industries estimated in mid-2011 that over 300,000 official Arduinos had been commercially produced, and in 2013 that 700,000 official boards were in users' hands The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to- serial converter.: "Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform; for a comparison with previous versions..
  • 17.
    HISTORY OF ARDUINO Arduinostarted in 2005 as a project for students at the Interaction design institute in Ivrea, Italy. At that time program students used a "BASIC Stamp" at a cost of $100, considered expensive for students. Massimo Banzi, one of the founders, taught at Ivrea, The name "Arduino" comes from a bar in Ivrea, where some of the founders of the project used to meet. The bar, in turn, has been named after Arduin of Ivrea, who was the margrave of Ivrea and king of Italy from 1002 to 1014.Colombian student Hernando Barragan created the Wiring development platform which served as the basis for Arduino. Following the completion of the Wiring platform, its lighter, less expensive versions were created and made available to the open-source community; associated researchers, including David Cuartielles, promoted the idea. The Arduino's initial core team consisted of Massimo Banzi, David Cuartielles, Tom Ignore, Gianluca Martino, and David Mellis
  • 18.
    DEVELOPMENT Arduino is open-sourcehardware: the Arduino hardware reference designs are distributed under a Creative Commons Attribution Share-Alike 2.5 license and are available on the Arduino Web site. Layout and production files for some versions of the Arduino hardware are also available. The source code for the IDE is available and released under the GNU General Public License, version 2. Although the hardware and software designs are freely available under copyleft licenses, the developers have requested that the name "Arduino" be exclusive to the official product and not be used for derivative works without permission. The official policy document on the use of the Arduino name emphasizes that the project is open to incorporating work by others into the official product. Several Arduino-compatible products commercially released have avoided the "Arduino" name by using "-duino" name variants.
  • 19.
    LIBRARIES To use anexisting library in a sketch, go to the Sketch menu, choose "Import Library", and pick from the libraries available. This will insert one or more #include statements at the top of the sketch and allow it to use the library. Because libraries are uploaded to the board with your sketch, they increase the amount of space it takes up. If a sketch no longer needs a library, simply delete its #include statements from the top of your code. These are the "official" libraries that are included in the Arduino distribution. EEPROM - reading and writing to "permanent" storage SoftwareSerial - for serial communication on any digital pins Stepper - for controlling stepper motors Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a net of devices or sensors. These libraries are compatible Wiring versions, and the links below point to the (excellent) Wiring documentation. Matrix - Basic LED Matrix display manipulation library Sprite - Basic image sprite manipulation library for use in animations with an LED matrix Contributed Libraries Libraries written by members of the Arduino community. DateTime - a library for keeping track of the current date and time in software. Firmata - for communicating with applications on the computer using a standard serial protocol. GLCD - graphics routines for LCD based on the KS0108 or equivalent chipset. LCD - control LCDs (using 8 data lines) LCD 4 Bit - control LCDs (using 4 data lines) LedControl - for controlling LED matrices or seven-segment displays with a MAX7221 or MAX7219. LedControl - an alternative to the Matrix library for driving multiple LEDs with Maxim chips. TextString - handle strings Metro - help you time actions at regular intervals MsTimer2 - uses the timer 2 interrupt to trigger an action every N milliseconds. OneWire - control devices (from Dallas Semiconductor) that use the One Wire protocol. PS2Keyboard - read characters from a PS2 keyboard. Servo - provides software support for Servo motors on any pins. Servotimer1 - provides hardware support for Servo motors on pins 9 and 10 Simple Message System - send messages between Arduino and the computer SSerial2Mobile - send text messages or emails using a cell phone (via AT commands over software serial) X10 - Sending X10 signals over AC power lines To install, unzip the library to a sub-directory of the hardware/libraries sub-directory of the Arduino application directory. Then launch the Arduino environment; you should see the library in the Import Library menu.
  • 20.
    HARDWARE An Arduino boardconsists of an Atmel 8-, 16- or 32-bit AVR microcontroller with complementary components that facilitate programming and incorporation into other circuits. An important aspect of the Arduino is its standard connectors, which lets users connect the CPU board to a variety of interchangeable add-on modules known as shields. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an I²CAn Arduino board consists of an Atmel 8-, 16- or 32-bit AVR microcontroller with complementary components that facilitate programming and incorporation into other circuits. An important aspect of the Arduino is its standard connectors, which lets users connect the CPU board to a variety of interchangeable add-on modules known as shields. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an I²C serial bus—so many shields can be stacked and used in parallel. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, andATmega2560. A handful of other processors have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs such as the LilyPad run at 8 MHz and dispense with the onboard voltage regulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an external programmer. This makes using an Arduino more default bootloader installed on Arduino UNO. At a conceptual level, when using the Arduino software stack, all boards are programmed over an RS-232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino boards contain a level shifter circuit to convert between RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB, implemented using USB-to-seriaadapter chips such as the FTDIFT232. Some boards, such as later-model Unos, substitute the FTDI chip with a separate AVR chip containing USB-to-serial firmware (itself reprogrammable via its own ICSP header). Other variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools instead of the ArduinoIDE, standard AVR ISP programming is used.) The Arduino board exposes most of the microcontroller's I/O pins for use by other circuits. The current Uno provide 14 digital I/O pins, six of which can produce pulse-width modulated signals, and six analog inputs, which can also be used as six digital I/O pins. These pins are on the top of the board, via female 0.10-inch (2.5 mm) headers. Several plug-in application shields are also commercially available. The Arduino Nano, and Arduino-compatible Bare Bones Board and
  • 21.
    Boarduino boards mayprovide male header pins on the underside of the board that can plug into solderless breadboards. There are many Arduino-compatible and Arduino-derived boards. Some are functionally equivalent to an Arduino and can be used interchangeably. Many enhance the basic Arduino by adding output drivers, often for use in school-level education to simplify the construction of buggies and small robots. Others are electrically equivalent but change the form factor, sometimes retaining compatibility with shields, sometimes not. Some variants use completely different processors, with varying levels of compatibility.serial bus—so many shields can be stacked and used in parallel. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, andATmega2560. A handful of other processors have been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some variants), although some designs run at 8 MHz and dispense with the onboard voltageregulator due to specific form-factor restrictions. An Arduino's microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an externalprogrammer. This makes using an Arduino more straightforward by allowing the use of an ordinary computer as the programmer. Currently, optiboot bootloader is the default bootloader installed on Arduino UNO. At a conceptual level, when using the Arduino software stack, all boards are programed over an RS- 232 serial connection, but the way this is implemented varies by hardware version. Serial Arduino boards contain a level shifter circuit to convert between RS-232-level and TTL-level signals. Current Arduino boards are programmed via USB, implemented using USB-to-serial adapter chips such as the FTDIFT232. Some boards, such as later-model Unos, substitute the FTDI chip with a separate AVR chip containing USB-to-serial firmware (itself reprogrammable via its own ICSP header). Other variants, such as the Arduino Mini and the unofficial Boarduino, use a detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When used with traditional microcontroller tools instead of the ArduinoIDE, standard AVR ISP programming is used.)equivalent to an Arduino and can be used interchangeably. Many enhance the basic Arduino by adding output drivers, often for use in school-level education to simplify the construction of buggies and small robots. Others are electrically equivalent but change the form factor, sometimes retaining compatibility with shields, sometimes not. Some variants use completely different processors, with varying levels of compatibility.
  • 22.
    SOFTWARE The Arduino integrateddevelopment environment (IDE) is a cross-platform application written in Java, and derives from the IDE for the Processing programming language and the Wiring projects. It is designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling and uploading programs to the board with a single click. A program or code written for Arduino is called a "sketch". Arduino programs are written in C or C++. The Arduino IDE comes with a software library called "Wiring" from the original Wiring project, which makes many common input/output operations much easier. The users need only to define two functions to make an executable cyclic executive program: • setup(): a function that runs once at the start of a program and that can initialize settings. • loop(): a function called repeatedly until the board powers off. Most Arduino boards contain an LED and a load resistor connected between the pin 13 and ground, which is a convenient feature for many simple tests. The previous code would not be seen by a standard C++ compiler as a valid program, so when the user clicks the "Upload to I/O board" button in the IDE, a copy of the code is written to a temporary file with an extra include header at the top and a very simple main() function at the bottom, to make it a valid C++ program. The Arduino IDE uses the GNU toolchain and AVR Libc to compile programs, and uses avr to upload programs to the board. As the Arduino platform uses Atmel microcontrollers, Atmel's development environment, AVR Studio or the newer Atmel Studio, may also be used to develop software for the Arduino.
  • 23.
    ARDUINO BOARD Looking atthe board from the top down, this is an outline of what you will see (parts of the board you might interact with in the course of normal use are highlighted): • Pins 2-13 (green) • Digital Pins 0-1/Serial In/Out - TX/RX (dark green) - These pins cannot be used for digital i/o (digitalRead and digitalWrite) if you are also using serial communication (e.g. Serial.begin). • Reset Button - S1 (dark blue) • In-circuit Serial Programmer (blue-green) • Analog In Pins 0-5 (light blue) • Power and Ground Pins (power: orange, grounds: light orange) • External Power Supply In (9-12VDC) - X1 (pink) Toggles External Power and USB Power (place jumper on two pins closest to Starting clockwise from the top center: • Analog Reference pin (orange) • Digital Ground (light green) • Digital desired supply) - SV1 (purple) • USB (used for uploading sketches to the board and for serial communication between the board and the computer; can be used to power the board) (yellow)
  • 24.
    DIGITAL PINS In additionto the specific functions listed below, the digital pins on an Arduino board can be used for general purpose input and output via the pinMode(), digitalRead(), and digitalWrite()commands. Each pin has an internal pull-up resistor which can be turned on and off using digitalWrite() (w/ a value of HIGH or LOW, respectively) when the pin is configured as an input. The maximum current per pin is 40 mA. • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. • 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 attachInterrupt() function for details. • PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function. On boards with an ATmega8, PWM output is available only on pins 9, 10, and 11. • BT Reset: 7. (Arduino BT-only) Connected to the reset line of the bluetooth module. • SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the Arduino language. • LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
  • 25.
    ANALOG PINS In additionto the specific functions listed below, the analog input pins support 10-bit analog-to- digital conversion (ADC) using the analogRead() function. Most of the analog inputs can also be used as digital pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19. Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as digital pins. • I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library (documentation on the Wiring website). POWER PINS • VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. Note that different boards accept different input voltages ranges, please see the documentation for your board. Also note that the LilyPad has no VIN pin and accepts only a regulated input. • 5V. The regulated power supply used to power the microcontroller and other components on the board. This can come either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V supply. • 3V3. (Diecimila-only) A 3.3 volt supply generated by the on-board FTDI chip. • GND. Ground pins. • AREF. Reference voltage for the analog inputs. Used with analogReference(). • Reset. (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board..
  • 26.
    Microcontrollers Microcontroller ATmega328P Operating Voltage5V Input Voltage (recommended) 7-12 V Input Voltage (limit) 6-20 V Digital I/O Pins 14 (of which 6 provide PWM Output) PWM Digital I/O Pins 6 Analog Input Pins 6 DC Current per I/O pin 20 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB (ATmega 328P) of which 0.5 KB used by bootloader SRAM 2 KB (ATmega 328P)
  • 27.
    EEPROM 1 KB(ATmega328P) Clock Speed 16 MHz Length 68.6 mm Width 53.4 mm Weight 25 g MEMORYSUMMARY DEVICE FLASH EEPROM RAM INTERRUPT SIZE ATmega48PA 4K Bytes 256 Bytes 512 Bytes 1 instruction word/vector ATmega88PA 8K Bytes 512 Bytes 1K Bytes 1 instruction word/vector ATmega168PA 16K Bytes 512 Bytes 1K Bytes 2 instruction word/vector ATmega328P 32K Bytes 1K Bytes 2K Bytes 2 instruction word/vector
  • 28.
    PROGRAMMING WITH ARDUINO TheArduino runs on a simplified version of the C programming language, with some extensions for accessing the hardware. In this guide, we will cover the subset of the programming language that is most useful to the novice Arduino designer. All Arduino instructions are one line. The board can hold a program hundreds of lines long and has space for about 1,000 two-byte variables. The Arduino executes programs at about 300,000 source code lines per sec. 4.1Creating a Program Programs are created in the Arduino development environment and then downloaded to the Arduino board. Code must be entered in the proper syntax which means using valid command names and a valid grammar for each code line. The compiler will catch and flag syntax errors before download. Sometimes the error message can be cryptic and you have to do a bit of hunting because the actual error occurred before what was flagged. Although your program may pass cleanly through the syntax checker, it still might not do what you wanted it to. Here is where you have to hone your skills at code debugging. The Arduino did what you told it to do rather than what you wanted it to do. The best way to catch these errors is to read the code line by line and be the computer. Having another person go through your code also helps. Skilled debugging takes practice. Program Formatting and Syntax Programs are entered line by line. Code is case sensitive which means "myvariable" is different than "MyVariable". Statements are any command. Statements are terminated with a semi-colon. A classic mistake is to forget the semi-colon so if your program does not compile, examine the error text and see if you forgot to enter a colon. Comments are any text that follows “//” on a line. For multi-line block comments, begin with “/*” and end with “*/”
  • 29.
    CONSTANT Constants are fixednumbers and can be entered as ordinary decimal numbers (integer only) or in hexadecimal (base 16) or in binary (base 2) as shown in the table below Decimal Hex Binary 17 100 0x64 B01100100 LABEL Labels are used to reference locations in your program. They can be any combination of letters, numbers and underscore (_), but the first character must be a letter. When used to mark a location, follow the label with a colon. When referring to an address label in an instruction line, don't use the colon. Here's an example repeat: digitalWrite(2,HIGH); delay(1000); digitalWrite(2,LOW); delay(1000); goto repeat; Use labels sparingly as they can actually make a program difficult to follow and challenging to debug. In fact, some C programmers will tell you to never use labels. VARIABLES Variables are allocated by declaring them in the program. Every variable must be declared. If a variable is declared outside the braces of a function, it can be seen everywhere in the program. If it is declared inside the braces of a function, the variable can only be seen within that function. Variables come in several flavors including byte (8-bit, unsigned, 0 to 255), word (16-bit, unsigned, 0 to 65,536), int (16-bit, signed, -32,768 to 32,767), and long (32-bit, signed, -2,147,483,648 to 2,147,483,647). Use byte variables unless you need negative numbers or numbers larger than 255, then use int variables. Using larger sizes than needed fills up precious memory space. Variable declarations generally appear at the top of the program byte i; word k; int length; int width; Variable names can be any combination of letters and numbers but must start with a letter. Names reserved for programming instructions cannot be used for variable names and will give you an error message
  • 30.
    Simple Commands This sectioncovers the small set of commands you need to make the Arduino do something useful. These commands appear in order of priority. You can make a great machine using only digital read, digital write and delay commands. Learning all the commands here will take you to the next level. PinMode This command, which goes in the setup() function, is used to set the direction of a digital I/O pin. Set the pin to OUTPUT if the pin is driving and LED, motor or other device. Set the pin to INPUT if the pin is reading a switch or other sensor. On power up or reset, all pins default to inputs. The Serial.print command Used to print data serially. For the command to work, the command Serial.begin(9600) must be placed in the setup() function. After the program is uploaded, you must open the Serial Monitor window to see the response. There are two forms of the print command. Serial.print() prints on the same line while Serial.println() starts the print on a new line.
  • 31.
    PROGRAMS 4.2 Glowing LED’sin sequence This program glows Led’s in sequence according to character typed from keyboard and also display that character on LCD screen. Code #include<LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); int thisPin; void setup() { lcd.begin(16,2); Serial.begin(9600); Serial.println("-----------Main Menu--------------"); Serial.println("Press a for LED1"); Serial.println("Press b for LED2"); Serial.println("Press c for LED3"); Serial.println("Press d for LED4"); Serial.println("Press e for LED5"); Serial.println("press any key to switch off the LED"); Serial.println("-------------------------------------"); for( thisPin=2;thisPin<7;thisPin++);
  • 32.
    { pinMode(thisPin,OUTPUT); } } void loop() { if(Serial.available()>0) { char rx=Serial.read(); switch(rx) { case'a': Serial.println("LED1 is ON"); lcd.setCursor(0,1); lcd.print("LED1"); digitalWrite(2,HIGH); break; case 'b': Serial.println("LED2 is ON"); lcd.setCursor(5,1); lcd.print("LED2"); digitalWrite(3,HIGH); break; case 'c': Serial.println("LED3 is ON"); lcd.setCursor(11,1); lcd.print("LED3"); digitalWrite(4,HIGH); break; case 'd': Serial.println("LED4 is ON"); lcd.setCursor(0,2); lcd.print("LED4"); digitalWrite(5,HIGH); break; case 'e':
  • 33.
    Serial.println("LED5 is ON"); lcd.setCursor(8,2); lcd.print("LED5"); digitalWrite(6,HIGH); break; default: for(intthisPin=2;thisPin<7;thisPin++) { digitalWrite(thisPin,LOW); } Serial.println("All LEDs are off"); lcd.clear(); } } }
  • 34.
    4.3 DIGITAL TEMPERATURESENSORINTERFACINGUSING LCD Components Required: 1 ) Developments board. 2) 2*16 LCD 3) Digital Temperature Sensor 4) Pot-Meter (10k) 5) Resistor 560 ohm 6) Bread Board 7) Couple of Jumper Wire Temperature Sensor - Waterproof (DS18B20) Description: This sealed digital temperature probe lets you precisely measure temperatures in wet environments with a simple 1-Wire interface. The DS18B20 provides 9 to 12-bit (configurable) temperature readings over a 1-Wire interface,so that only one wire (and ground) needs to be connected from a central microprocessor. What is 2*16 LCD • LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. • A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data. Circuit Connection of Temperature Sensors Using LCD and Atmega
  • 35.
    Code : #include<OneWire.h> #include<DallasTemperature.h> #include<LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); #definesingleWire 6 OneWire ourWire(singleWire); DallasTemperature sensors(&ourWire); void setup() { Serial.begin(9600); Serial.print("Temperature value"); lcd.begin(16,2); lcd.print("***Temperature***"); sensors.begin(); } void loop() { sensors.requestTemperatures(); Serial.print(sensors.getTempCByIndex(0)); Serial.println(" C");
  • 36.
  • 37.
    4.4 KEYPAD INTERFACING ComponentsRequired: 1.) Custom Board 2.) LED RED 3.) LED GREEN 4.) POT-METER(10k) 5.) 2 x 16 LCD 6.) Breadboard 7.) Resistor 560 ohm 8.) Couple of Jumper Wire 9.) Hex-Keypad Interfacing hex keypad to Atmega-328p This article is about how to interface a hex keypad to Atmega-328. Hex keypad is a very important component in embedded systems and the typical applications are code locks, calculators, automation systems or simply any thing that requires a character or numeric input. Hex keypad. Hex key pad is simply an arrangement 0f 16 push button switches in a 4X4 matrix form. Typically a hex keypad will have keys for number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and letters A, B, C, D, *, #. The hex keypad will have 8 connection wires namely R1, R2, R3, R4 and C1, C2, C3, C4 representing the rows and columns respectively. The schematic diagram and photo of a typical hex keypad is shown in the figure below. Code :
  • 38.
    #include<Password.h> #include<Keypad.h> #include<LiquidCrystal.h> Password password=Password("1#3*5"); int len=5;//sizeof password int ledRed=11;//for Wrong int ledGreen=12;//for Success int ilosc;//number of clicks LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); const byte ROWS=4; const byte COLS=4; char keys[ROWS][COLS]={ {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; byte rowPins[ROWS]={5,4,3,2}; byte colPins[COLS]={9,8,7,6}; Keypad keypad=Keypad(makeKeymap(keys),rowPins,colPins,ROWS,COLS); void setup() { keypad.addEventListener(keypadEvent); Serial.begin(9600); pinMode(ledRed,OUTPUT); pinMode(ledGreen,OUTPUT); lcd.begin(16,2); lcd.setCursor(1,0); lcd.print("PLEASE ENTER PIN"); } void loop() { keypad.getKey(); } void keypadEvent(KeypadEvent eKey) {
  • 39.
    switch(keypad.getState()) { case PRESSED: Serial.print("pressed: "); Serial.println(eKey); } Serial.println(ilosc); if(ilosc== 1) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("*_"); } if(ilosc == 2) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("**_"); } if(ilosc == 3) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("***_"); } if(ilosc==4) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> ");
  • 40.
    lcd.setCursor(0,1); lcd.print("****_"); } if(ilosc==5) { lcd.clear(); lcd.setCursor(1,0); lcd.print(" <PIN> "); lcd.setCursor(0,1); lcd.print("*****_"); } if(ilosc== len) { delay(250); checkPassword(); ilosc=0; } } void checkPassword() { if(password.evaluate()) { ilosc = 0; Serial.println("Success"); digitalWrite(ledRed,LOW); digitalWrite(ledGreen,HIGH); lcd.clear(); lcd.setCursor(0,1); lcd.print("<<SUCCESS>>"); } else { ilosc = 0; password.reset(); Serial.println("Wrong"); digitalWrite(ledGreen,LOW);
  • 41.
  • 42.
    4.5 GPS INTERFACING ComponentsRequired: 1.) Custom Board 2.) POT-METER(10k) 3.) 2 x 16 LCD 4.) Breadboard 5.) Resistor 560 ohm 6.) Couple of Jumper Wire 7.) Ublox GPS Module What is GPS? The Global Positioning System (GPS) is a satellite-based navigation system made up of a network of 24 satellites placed into orbit by the U.S. Department of Defense. GPS was originally intended for military applications, but in the 1980s, the government made the system available for civilian use. GPS works in any weather conditions, anywhere in the world, 24 hours a day. There are no subscription fees or setup charges to use GPS. How Does GPS Work: The GPS system currently has 31 active satellites in orbits inclined 55 degrees to the equator. The satellites orbit about 20,000km from the earth's surface and make two orbits per day.The orbits are designed so that there are always 6 satellites in view, from most places on the earth. The GPS receiver can determine your position in three dimensions - east, north and altitude. GPS Receiver: GPS Receiver received the information in string format, transmitted by Satellites, which uses this information to calculate different parameters between it and satellites. With information from satellites, a GPS receiver can fix it location on the ground from the known position of the satellites. Now I want to drag your attention on the purpose of this project. In this project, we are going to display ‘Latitude & Longitude’ used for positioning of an object on the earth. So let’s talk about how a GPS receiver fixes its location on the ground, as i above said and the find the location of an object on the earth. Pin Configuration of U-Blox GPS: 1.VCC: +5v Power Supply 2.TX : Data Transmission 3.RX : Data Receiver 4.GND: Ground
  • 43.
    Code : #include<TinyGPS.h> #include<SoftwareSerial.h> long lat,lon; TinyGPSgps; SoftwareSerial gpsSerial(3,4); void setup() { Serial.begin(9600); gpsSerial.begin(9600); } void loop() { while(gpsSerial.available()) { if(gps.encode(gpsSerial.read())) { gps.get_position(&lat,&lon);
  • 44.
    Serial.print("Receive GPS signalis:"); Serial.println("Position:"); Serial.print("Longitude:"); Serial.print(lon); Serial.print(" "); Serial.print("Latitude:"); Serial.print(lat); } } }
  • 45.
    4.6 RFID INTERFACING Code: //add libraries to your project #include<AddicoreRFID.h> #include<LiquidCrystal.h> #include<SPI.h> #define uchar unsigned char #define uint unsigned int //class to include functions of rfid AddicoreRFID myRFID; int chipSelectPin=10; #define MAX_LEN 16 void setup(){ //led lcd.begin(16,2); lcd.println("RFID World"); pinMode(6,OUTPUT); //convert binary to human readable form SPI.begin(); //initialise or activate rfid //as setup execute only once digitalWrite(6,LOW); //initialise the rfid myRFID.AddicoreRFID_Init(); } unsigned char structure[16]; unsigned char status; void loop(){ uchar status; uchar str[MAX_LEN]; status=myRFID.AddicoreRFID_Request(PICC_REQIDL,str); status=myRFIDAddicoreRFID_Anticoll(str); if(status==MI_OK){ lcd.setCursor(0,1); lcd.print("Tag ID:"); lcd.setCursor(8,1);
  • 46.
  • 47.
    4.7 ULTRASONIC SENSOR ComponentsRequired: 1.) Custom Board 2.) POT-METER(10k) 3.) 2 x 16 LCD 4.) Breadboard 5.) Resistor 560 ohm 6.) Couple of Jumper Wire 7.) HC-SR04 Interfacing of ultrasonic Sensors withAtmega-328p HC-SR04 Ultrasonic distance sensors is a popular and low cost solution for non-contact distance measurement function. It is able to measure distances from 1cm to 400cm with an accuracy of about 3mm. This module includes ultrasonic transmitter, ultrasonic receiver and its control circuit. HC-SR04 module has 4 pins : VCC – 5V power supply TRIG – Trigger Pin ECHO – Echo Pin GND – Ground power supply
  • 48.
    Code : #include<LiquidCrystal.h> LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); constint trigPin=2; const int echoPin=4; void setup() { lcd.begin(16,2); Serial.begin(9600); Serial.print("Distance Between Object and Sensors"); } void loop() { long inches,cm,duration; pinMode(trigPin,OUTPUT); digitalWrite(trigPin,LOW); delayMicroseconds(2); digitalWrite(trigPin,HIGH); delayMicroseconds(10);
  • 49.
  • 50.
    CHAPTER 6 :RESULTS AND DISCUSSIONS 6.1 Results and Conclusions Over the years,Arduino has went out to become a huge success and a common name among students.With google deploying it,people’s imagination has went out to much higher level than before.A developer in the annual GOOGLE IO conference said “when Arduino and Android coming together,this really proves “INFINITY EXISTS” in the future”.I think a study on arduino and practical experiments on arduino must be added for UG courses of engineering,to help students to leverage their talents,and imagination.
  • 51.
    CONCLUSION Arduino in conjunctionwith participatory design and interactive design yields successful results. Once users are knowledgeable of the Arduino programming language they are able to implement a variety of solutions to numerous problems.Tangible and graphical programming languages have been proven to be successful in stimulating and educating programmers. Both have been found to make an improvement in learning when used with participatory and interactive design. In terms of learning how to program, tangible programming has shown better results. Thus, there is an opportunity to develop a tangible or graphical programming language for Arduino. Possibly a combination of the two along with adopting participatory and interactive design practices could yield an improved Arduino programming language that all of its users can use with ease and creativity. Focussing on how the users want to program and not how they should theoretically be programming.
  • 52.
    REFERENCES 1.http://www.arduino.cc -Arduino officialwebpage 2.http://en.wikipedia.org/wiki/Arduino -wikipedia 3.http://www.instructables.com 4.http://www.adafruit.com 5.http://www.electroschematics.com