SlideShare a Scribd company logo
1 of 26
INTERNET OF THINGS:
ARDUINO AND C
PROGRAMMING
COMBINING THE TANGIBLE AND THE VOLATILE INTO ONE
Punit Goswami
ARDUINO ENVIRONMENT
THE ARDUINO BOARD, ITS SOFTWARE COMPONENT AND OTHER ADD-ON HARDWARE
ARDUINO DEVELOPMENT BOARD
• Eight bit microcontroller – brain of the board
• USB Port – to communicate with the desktop/laptop
• USB controller chip – manages USB transferred data
• IO pins – board’s connection to the outside world
• Quartz oscillator – board’s time keeper
• Reset button – taking the board back to its initial state
• External power jack – power from dedicated source
Co-axial jack, but USB can also be used
INPUT/OUTPUT PINS (I/O PINS)
 Top and bottom rows of the board
 Holes in the board which we can stick wires in
 Holes are connected to the chips through traces on-board
 14 Digital I/O pins on top [0-13]
Highs – 5 volts Lows – 0 volts Max Current - 40 mA
 6 Analog input pins on the bottom [A0 – A5]
 Power output pins on the bottom [ 5v , 3.3 v ]
 Reset pin to reset the board to initial state
MICROCONTROLLERS
 Two microcontrollers on the board
 Main ATmega328 – 8 bit microcontroller
User programmable, runs user-written application code
Carries firmware, like bootloader
 ATmega16U2
Handles the communication with the USB interface, not
directly accessible
STORAGE & MEMORY
 Non-volatile flash memory for storage
 32 kilobytes in size
 Static Random Access Memory (SRAM) for memory (volatile)
 3 kilobytes in size
CLOCK
 16 MHz clock speed ~ 16 million operations per second
 Helps synchronize all components together
 Keeping track of occurrence of events
PROGRAMMING FIRMWARE
 The ISCP headers can be used to program the firmware on
the board
 ICSP1 for the main ATmega328 microcontroller
 ICSP2 for the ATmega16U2 microcontroller
 Special equipment are required in order to re-program the
firmware through these headers
SOFTWARE ENVIRONMENT
• Arduino IDE – Integrated Development Environment
• Can be programmed using other IDEs too, like Eclipse
• Arduino IDE is more versatile
• Needs no special drivers or additional components
• Available for Windows, Linux and Mac
• Cross compiler – compiles for a different target platform than the one being programmed on
IDE – SOFTWARE TOOL FOR PROGRAMMING
 File operations and other general options on top
 Buttons for most commonly used options (Verify, Upload, etc.)
 Main window – Text editor for writing code
 Message area – for messages to the programmer
OPTIONS BUTTONS
Buttons on the top have the most common ,useful operations
 Verify – compiles the code and checks for errors
 Uploads – compiles the code, uploads it to the board. Works only
if the board is connected
 New – creates a new sketch, a new program
 Open – opens an existing sketch
 Save – saves the current sketch in the directory of your choice
 Serial Monitor – opens window to communicate with the board
TARGET PLATFORM
• ATmega328 – Arduino Uno’s processor
• Arduino shields – add on hardware for specific purposes
• Shields need no complicated circuitry – prewired
• Stacks of shields on top of the Arduino
• Prefabricated libraries of methods
ARDUINO SHIELDS
The prominent reason that Arduino got so popular
 Additional hardware to do particular, complex tasks
 Form of separate boards
 Pre-wired pins that stick into holes in Arduino
 Stack on top of the Arduino to make connections
 Pre-written functions for operations of these boards
 Open-source designs in most of the cases, third party
Complete list of shields at http://www.shieldlist.org
OPEN SOURCE
• Hardware – the board’s design is open source
http://www.arduino.cc
• Software – the IDE is open source, written in Java, modifiable, redistributable
• Open source community – easily available codes and help on troubleshooting
SETTING UP THE ENVIRONMENT
LEARNING TO CODE IN C/C++ FOR ARDUINO
RUNNING IDE ON WINDOWS
 Emacs or NotePad++ text editor
 Gcc C compiler
 The debugger, gdb
IDE provides one-stop solution
ARDUINO IDE
 Require Java Runtime Environment
 Write codes in general C language
 setup() – Initiates the variables and sets up device instances
 loop() – Runs the code that contains operations and
manipulations, iterates infinitely
BLINK LED EXAMPLE
 Pin 13 is represented by numeral 13
 digitalWrite() writes voltage values to pins
 delay() sets delays in milliseconds
 HIGH – 5v LOW – 0v
ARDUINO PROGRAMS AND THE BUILD PROCESS
HOW IT IS SAME BUT DIFFERENT TO CODE FOR THE BOARDS
Source
code
Executable
file
Hex file
Uploaded
to board
ARDUINO TOOLCHAIN
Steps taken post code authoring
 Source code(sketch) is compiled to an executable format
 Executable file is linked with libraries and interpreted into a
hex file
 Hex file is uploaded to board
Starts executing right away
CROSS COMPILATION
Compile on one machine, but the target is another machine.
E.g.: compiling it on an Intel processor, compiling it for an AVR processor
 avr-gcc – C compiler for AVR targets, gives a *.o file
 avr-lnk – links library object files, results in a *.elf file
 avr-objcopy – change the *.elf file into Arduino compatible *.hex file
DEBUGGING AND TROUBLESHOOTING
REMOVING ERRORS AND TAKING CARE OF REPAIR AND MAINTENANCE
DEBUGGING
• Finding reasons of erroneous execution or failure of execution
• Software problems
• Require ‘controllability’ and ‘observability’
• Controllability: the ability to control sources of data that are used by the system
Allows to do testing to test certain circumstances that might be causing a bug or triggering a bug at
any rate
• Observability: the ability to observe intermediate and final results
An oscilloscope, multi-meter, or the serial monitor could be used
REAL TIME MONITORING
• Includes dynamic observation of the target and its state
• Viewing data about the execution as it occurs
• Not intrusive in terms of performance
• Important for timing constraint IoT systems
• Provides timing and functional accuracy
REMOTE DEBUGGING
Remote Debugger
• Host computer acts as debugger for a code that runs on the remote target system
• Host computer are also the systems that the programmer programs on
• Host provides the platform to interface with the debugging environment.
• Provides good run control, not good for testing timing
Embedded Debug Interface
• Seen in modern processors, Arduino and its likes have trace macrocells
• Built in to the processor
• Hardware dedicated to do debugging directly
SERIAL PROTOCOLS FOR DEBUGGING
• UART: Universal Asynchronous Receiver/Transmitter, an old protocol, still useful though.
• Low hardware overhead
• Transmits at 9600 baud
• START and STOP buts are used for synchronization
• The bits in between a START bit and the next STOP bit is the data
• To distinguish, the receiver samples at 16 times higher rate than the baud rate
• Serial interface can be used to both send data to and from the Arduino board

More Related Content

What's hot

What's hot (20)

Arduino
ArduinoArduino
Arduino
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino Microcontroller
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
 
Ardui no
Ardui no Ardui no
Ardui no
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
 
Arduino presentation by_warishusain
Arduino presentation by_warishusainArduino presentation by_warishusain
Arduino presentation by_warishusain
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
 
Lesson sample introduction to arduino
Lesson sample   introduction to arduinoLesson sample   introduction to arduino
Lesson sample introduction to arduino
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Arduino - Classes and functions
Arduino - Classes and functionsArduino - Classes and functions
Arduino - Classes and functions
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
Introduction to Arduino and Hands on to Iot
Introduction to Arduino and Hands on to IotIntroduction to Arduino and Hands on to Iot
Introduction to Arduino and Hands on to Iot
 
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIYArduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 2 - Advance Arduino & DIY
 
Arduino Platform with C programming.
Arduino Platform with C programming.Arduino Platform with C programming.
Arduino Platform with C programming.
 
Arduino uno
Arduino unoArduino uno
Arduino uno
 
Aurdino presentation
Aurdino presentationAurdino presentation
Aurdino presentation
 

Similar to Arduino and c programming

Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoDamien Magoni
 
Embedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerEmbedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerArun Kumar
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfssusere5db05
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptxaravind Guru
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptxshivagoud45
 
aurduino-200107075953.pdf
aurduino-200107075953.pdfaurduino-200107075953.pdf
aurduino-200107075953.pdfHebaEng
 
Arduino: On-board components description, IDE and Programming
Arduino: On-board components description, IDE and Programming Arduino: On-board components description, IDE and Programming
Arduino: On-board components description, IDE and Programming Pawan Dubey, PhD
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptxAkshat Bijronia
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityAhmed Magdy Farid
 
Lecture 3 (tool stick platform) rv01
Lecture 3 (tool stick platform) rv01Lecture 3 (tool stick platform) rv01
Lecture 3 (tool stick platform) rv01cairo university
 
Embedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptxEmbedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptxaartis110
 
Lecture 1 Introduction.pptx
Lecture 1 Introduction.pptxLecture 1 Introduction.pptx
Lecture 1 Introduction.pptxOrchestra2
 
Embedded application development
Embedded application developmentEmbedded application development
Embedded application developmentAakash Raj
 
EC8791 designing with computing platform
EC8791 designing with computing platformEC8791 designing with computing platform
EC8791 designing with computing platformRajalakshmiSermadurai
 
Embedded system and its platforms
Embedded system and its platformsEmbedded system and its platforms
Embedded system and its platformsMrunal Deshkar
 
Embedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptxEmbedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptxlematadese670
 

Similar to Arduino and c programming (20)

arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Embedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontrollerEmbedded system programming using Arduino microcontroller
Embedded system programming using Arduino microcontroller
 
Arduino course
Arduino courseArduino course
Arduino course
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptx
 
Introduction of Arduino Uno
Introduction of Arduino UnoIntroduction of Arduino Uno
Introduction of Arduino Uno
 
Arduino_Beginner.pptx
Arduino_Beginner.pptxArduino_Beginner.pptx
Arduino_Beginner.pptx
 
aurduino-200107075953.pdf
aurduino-200107075953.pdfaurduino-200107075953.pdf
aurduino-200107075953.pdf
 
Arduino: On-board components description, IDE and Programming
Arduino: On-board components description, IDE and Programming Arduino: On-board components description, IDE and Programming
Arduino: On-board components description, IDE and Programming
 
arduino.pdf
arduino.pdfarduino.pdf
arduino.pdf
 
Introduction to Arduino.pptx
Introduction to Arduino.pptxIntroduction to Arduino.pptx
Introduction to Arduino.pptx
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA University
 
Lecture 3 (tool stick platform) rv01
Lecture 3 (tool stick platform) rv01Lecture 3 (tool stick platform) rv01
Lecture 3 (tool stick platform) rv01
 
Embedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptxEmbedded L1_notes_unit2_architecture.pptx
Embedded L1_notes_unit2_architecture.pptx
 
Lecture 1 Introduction.pptx
Lecture 1 Introduction.pptxLecture 1 Introduction.pptx
Lecture 1 Introduction.pptx
 
Embedded application development
Embedded application developmentEmbedded application development
Embedded application development
 
EC8791 designing with computing platform
EC8791 designing with computing platformEC8791 designing with computing platform
EC8791 designing with computing platform
 
Embedded system and its platforms
Embedded system and its platformsEmbedded system and its platforms
Embedded system and its platforms
 
Embedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptxEmbedded programming Embedded programming (1).pptx
Embedded programming Embedded programming (1).pptx
 

Recently uploaded

Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosVictor Morales
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfalene1
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsapna80328
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 

Recently uploaded (20)

Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitos
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveying
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 

Arduino and c programming

  • 1. INTERNET OF THINGS: ARDUINO AND C PROGRAMMING COMBINING THE TANGIBLE AND THE VOLATILE INTO ONE Punit Goswami
  • 2. ARDUINO ENVIRONMENT THE ARDUINO BOARD, ITS SOFTWARE COMPONENT AND OTHER ADD-ON HARDWARE
  • 3. ARDUINO DEVELOPMENT BOARD • Eight bit microcontroller – brain of the board • USB Port – to communicate with the desktop/laptop • USB controller chip – manages USB transferred data • IO pins – board’s connection to the outside world • Quartz oscillator – board’s time keeper • Reset button – taking the board back to its initial state • External power jack – power from dedicated source Co-axial jack, but USB can also be used
  • 4. INPUT/OUTPUT PINS (I/O PINS)  Top and bottom rows of the board  Holes in the board which we can stick wires in  Holes are connected to the chips through traces on-board  14 Digital I/O pins on top [0-13] Highs – 5 volts Lows – 0 volts Max Current - 40 mA  6 Analog input pins on the bottom [A0 – A5]  Power output pins on the bottom [ 5v , 3.3 v ]  Reset pin to reset the board to initial state
  • 5. MICROCONTROLLERS  Two microcontrollers on the board  Main ATmega328 – 8 bit microcontroller User programmable, runs user-written application code Carries firmware, like bootloader  ATmega16U2 Handles the communication with the USB interface, not directly accessible
  • 6. STORAGE & MEMORY  Non-volatile flash memory for storage  32 kilobytes in size  Static Random Access Memory (SRAM) for memory (volatile)  3 kilobytes in size
  • 7. CLOCK  16 MHz clock speed ~ 16 million operations per second  Helps synchronize all components together  Keeping track of occurrence of events
  • 8. PROGRAMMING FIRMWARE  The ISCP headers can be used to program the firmware on the board  ICSP1 for the main ATmega328 microcontroller  ICSP2 for the ATmega16U2 microcontroller  Special equipment are required in order to re-program the firmware through these headers
  • 9. SOFTWARE ENVIRONMENT • Arduino IDE – Integrated Development Environment • Can be programmed using other IDEs too, like Eclipse • Arduino IDE is more versatile • Needs no special drivers or additional components • Available for Windows, Linux and Mac • Cross compiler – compiles for a different target platform than the one being programmed on
  • 10. IDE – SOFTWARE TOOL FOR PROGRAMMING  File operations and other general options on top  Buttons for most commonly used options (Verify, Upload, etc.)  Main window – Text editor for writing code  Message area – for messages to the programmer
  • 11. OPTIONS BUTTONS Buttons on the top have the most common ,useful operations  Verify – compiles the code and checks for errors  Uploads – compiles the code, uploads it to the board. Works only if the board is connected  New – creates a new sketch, a new program  Open – opens an existing sketch  Save – saves the current sketch in the directory of your choice  Serial Monitor – opens window to communicate with the board
  • 12. TARGET PLATFORM • ATmega328 – Arduino Uno’s processor • Arduino shields – add on hardware for specific purposes • Shields need no complicated circuitry – prewired • Stacks of shields on top of the Arduino • Prefabricated libraries of methods
  • 13. ARDUINO SHIELDS The prominent reason that Arduino got so popular  Additional hardware to do particular, complex tasks  Form of separate boards  Pre-wired pins that stick into holes in Arduino  Stack on top of the Arduino to make connections  Pre-written functions for operations of these boards  Open-source designs in most of the cases, third party Complete list of shields at http://www.shieldlist.org
  • 14. OPEN SOURCE • Hardware – the board’s design is open source http://www.arduino.cc • Software – the IDE is open source, written in Java, modifiable, redistributable • Open source community – easily available codes and help on troubleshooting
  • 15. SETTING UP THE ENVIRONMENT LEARNING TO CODE IN C/C++ FOR ARDUINO
  • 16. RUNNING IDE ON WINDOWS  Emacs or NotePad++ text editor  Gcc C compiler  The debugger, gdb IDE provides one-stop solution
  • 17. ARDUINO IDE  Require Java Runtime Environment  Write codes in general C language  setup() – Initiates the variables and sets up device instances  loop() – Runs the code that contains operations and manipulations, iterates infinitely
  • 18. BLINK LED EXAMPLE  Pin 13 is represented by numeral 13  digitalWrite() writes voltage values to pins  delay() sets delays in milliseconds  HIGH – 5v LOW – 0v
  • 19. ARDUINO PROGRAMS AND THE BUILD PROCESS HOW IT IS SAME BUT DIFFERENT TO CODE FOR THE BOARDS
  • 20. Source code Executable file Hex file Uploaded to board ARDUINO TOOLCHAIN Steps taken post code authoring  Source code(sketch) is compiled to an executable format  Executable file is linked with libraries and interpreted into a hex file  Hex file is uploaded to board Starts executing right away
  • 21. CROSS COMPILATION Compile on one machine, but the target is another machine. E.g.: compiling it on an Intel processor, compiling it for an AVR processor  avr-gcc – C compiler for AVR targets, gives a *.o file  avr-lnk – links library object files, results in a *.elf file  avr-objcopy – change the *.elf file into Arduino compatible *.hex file
  • 22. DEBUGGING AND TROUBLESHOOTING REMOVING ERRORS AND TAKING CARE OF REPAIR AND MAINTENANCE
  • 23. DEBUGGING • Finding reasons of erroneous execution or failure of execution • Software problems • Require ‘controllability’ and ‘observability’ • Controllability: the ability to control sources of data that are used by the system Allows to do testing to test certain circumstances that might be causing a bug or triggering a bug at any rate • Observability: the ability to observe intermediate and final results An oscilloscope, multi-meter, or the serial monitor could be used
  • 24. REAL TIME MONITORING • Includes dynamic observation of the target and its state • Viewing data about the execution as it occurs • Not intrusive in terms of performance • Important for timing constraint IoT systems • Provides timing and functional accuracy
  • 25. REMOTE DEBUGGING Remote Debugger • Host computer acts as debugger for a code that runs on the remote target system • Host computer are also the systems that the programmer programs on • Host provides the platform to interface with the debugging environment. • Provides good run control, not good for testing timing Embedded Debug Interface • Seen in modern processors, Arduino and its likes have trace macrocells • Built in to the processor • Hardware dedicated to do debugging directly
  • 26. SERIAL PROTOCOLS FOR DEBUGGING • UART: Universal Asynchronous Receiver/Transmitter, an old protocol, still useful though. • Low hardware overhead • Transmits at 9600 baud • START and STOP buts are used for synchronization • The bits in between a START bit and the next STOP bit is the data • To distinguish, the receiver samples at 16 times higher rate than the baud rate • Serial interface can be used to both send data to and from the Arduino board

Editor's Notes

  1. In circuit serial programmer