SlideShare a Scribd company logo
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 (20)

PPTX
Arduino : how to get started
동호 손
 
ODP
Introduction to Arduino
Richard Rixham
 
PPTX
Introduction to Arduino
Green Moon Solutions
 
PPT
Device Drivers
Suhas S R
 
PPT
Intro to Arduino
avikdhupar
 
PPT
arduino
jhcid
 
PPT
Arduino
vipin7vj
 
PPTX
RISC-V Introduction
Yi-Hsiu Hsu
 
PPTX
Bios
Ivan Chkalov
 
PDF
IOTC08 The Arduino Platform
Eoin Brazil
 
PPTX
Nodemcu - introduction
Michal Sedlak
 
PPTX
Arduino IDE
mahalakshmimalini
 
PPTX
Introduction to Arduino
Omer Kilic
 
PPTX
PPT ON Arduino
Ravi Phadtare
 
PPTX
My arduino presentation
Sham Arsenal
 
PPTX
Introduction to arduino
Ahmed Sakr
 
PPS
What is Arduino ?
Niket Chandrawanshi
 
PPT
Bios ( Basic Input Output System )
Jesthine Nesshal
 
PPTX
Introduction to arduino!
Makers of India
 
PPTX
Ardui no
Amol Sakhalkar
 
Arduino : how to get started
동호 손
 
Introduction to Arduino
Richard Rixham
 
Introduction to Arduino
Green Moon Solutions
 
Device Drivers
Suhas S R
 
Intro to Arduino
avikdhupar
 
arduino
jhcid
 
Arduino
vipin7vj
 
RISC-V Introduction
Yi-Hsiu Hsu
 
IOTC08 The Arduino Platform
Eoin Brazil
 
Nodemcu - introduction
Michal Sedlak
 
Arduino IDE
mahalakshmimalini
 
Introduction to Arduino
Omer Kilic
 
PPT ON Arduino
Ravi Phadtare
 
My arduino presentation
Sham Arsenal
 
Introduction to arduino
Ahmed Sakr
 
What is Arduino ?
Niket Chandrawanshi
 
Bios ( Basic Input Output System )
Jesthine Nesshal
 
Introduction to arduino!
Makers of India
 
Ardui no
Amol Sakhalkar
 

Similar to Arduino and c programming (20)

PPT
Arduino Platform with C programming.
Govind Jha
 
PDF
Oop 2014 embedded systems with open source hardware v2
Michael Stal
 
PPTX
Arduino
Jerin John
 
PDF
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
PPT
Arduino presentation by_warishusain
student
 
PDF
Introduction to Arduino
Damien Magoni
 
PPTX
Internet of Things prescribed by University
Sanjay Kumar
 
PPTX
Up and running with Arduino
KUET
 
PDF
aurduino-200107075953.pdf
HebaEng
 
PPTX
Arduino: On-board components description, IDE and Programming
Pawan Dubey, PhD
 
PPT
Embedded system programming using Arduino microcontroller
Arun Kumar
 
PPTX
Arduino
Madugula Kumar
 
PPTX
Introduction to the Arduino
Wingston
 
PPTX
Q2 Arduino Draft Q2 Arduino Draft Q2 Arduino Draft
Kameshvra Dela Cruz
 
PPT
ARDUINO_presentation_by_Ravishankar_Pati.ppt
DeanSchoolofElectric1
 
PPT
ARDUINO_presentation
SubhodeepDey10
 
DOCX
Winter traning arduino report final
Govind Jha
 
PPTX
INTRODUCTION_TO_ARDUINO uno, applications
ssuser478d0e
 
PDF
4 Introduction to Arduino.pdf
RynefelElopre2
 
Arduino Platform with C programming.
Govind Jha
 
Oop 2014 embedded systems with open source hardware v2
Michael Stal
 
Arduino
Jerin John
 
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Arduino presentation by_warishusain
student
 
Introduction to Arduino
Damien Magoni
 
Internet of Things prescribed by University
Sanjay Kumar
 
Up and running with Arduino
KUET
 
aurduino-200107075953.pdf
HebaEng
 
Arduino: On-board components description, IDE and Programming
Pawan Dubey, PhD
 
Embedded system programming using Arduino microcontroller
Arun Kumar
 
Introduction to the Arduino
Wingston
 
Q2 Arduino Draft Q2 Arduino Draft Q2 Arduino Draft
Kameshvra Dela Cruz
 
ARDUINO_presentation_by_Ravishankar_Pati.ppt
DeanSchoolofElectric1
 
ARDUINO_presentation
SubhodeepDey10
 
Winter traning arduino report final
Govind Jha
 
INTRODUCTION_TO_ARDUINO uno, applications
ssuser478d0e
 
4 Introduction to Arduino.pdf
RynefelElopre2
 
Ad

Recently uploaded (20)

PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Ad

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

  • #9: In circuit serial programmer