SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Signals
0 Information is transferred in the digital/analogue world by
 signals.

0 Electrical Signals are given a logic equivalency to enable
 control and sensing from the physical universe.

0 1 == High == True == 3-5V

0 0 == Low == False == 0-2V

0 And thus the binary number system was born.
Digital and Analogue
            information
0 Signals can be defined as any time varying quantity
 that can be said to represent information.

0 Digital signals, at any given point of time take up only
 one of a few discrete predefined states.

0 Analogue signals are not restricted to any particular
 state but continuously changes itself w.r.t. time.
Hardware communication
0 Every electronic system will have two logic levels called
 VCC and GND.

0 Analogue signals in this can take any value between VCC
 and GND.

0 Digital Signals can only take the states of VCC and GND
 states.

0 Digital devices either control or respond to either VCC or
 GND.
Ports
0 A microcontroller can digitally communicate with the
 outside world through Ports.

0 Every microcontroller has its own PORTs controlled
 by specific port registers.

0 Ports are a collection of PINS on the microcontroller.

0 Each pin can be controlled digitally by the
 microcontroller.
PORTS on the arduino
0 The atmega328 has three ports
   0 B (digital pin 8 to 13)
   0 C (analog input pins)
   0 D (digital pins 0 to 7)


0 Each Port has a
   0 PORTx register that controls the value of the port.
   0 DDRx register that controls the port from output/input
     mode.
Digital Pins
0 Numbered 1 – 13 on the ardiono.


0 Can be set to Input/Output by pinMode(pin) function.


0 Can be set to output by digitalwrite(pin, state)
 function.

0 digitalread(pin) returns the state of the pin.
Digital PIN as output
0 The pin is in a state of low impedance.

0 This means the pin can supply current to other
 circuits. (40mA)

0 Shorts or attempting to draw more current can
 damage the transistors on that pin (or fry the board).

0 Use resistors to limit current from the pins. (1-
 10kohms)
LEDs
0 Light Emitting diode.

0 Use R = (VS - VL) / I to calculate the
  resistor value to put in series.
  0 Vs = 5V; VL = 2V (depends on color)
  0 I = 40mA (max current required)

0 Do not connect LEDs in parallel!!

0 The longer end is VCC and the shorter end
  is GND.
PIN13 on the Arduino
0 The arduino has an LED + resistor mounted on the
 board.

0 Open the program in folder 1. Blink in the arduino IDE.
0 Upload that program onto the board.
0 Watch blinky!


0 Can you make it blink faster?
0 Then slower?
Connecting External LED
0 Open folder 2.LED Breadboard


0 Connect LEDs as shown in the circuit diagram.


0 Avoid connecting multiple LEDs to a single PIN.


0 If the PIN is HIGH the LED will light up.
Digital Input
0 Digital Input can be sensed by all digital pins of the
  arduino.

0 Pins when set up as inputs are said to be in a High
  impedance state.
0 Which means they tend to draw very little current from the
  circuit they are sensing and that means that small changes
  in current are enough to change the state of the PIN.

0 If an input pin is left unconnected:
   0 State may change randomly
   0 Pin may capacitively couple & report the state of a nearby pin.
Switches
0 Switches are mechanical devices that “switch”
 between VCC and GND states.
Switching states
0 We need to switch between VCC and GND to use with
  digitalread().

0 But, tactile switches can only open and close circuits.

0 In each of the cases, if switch is pressed, the PIN goes into a
  state, when released the PIN is disconnected or in a random
  state.
Enter Pull-down resistors
0 Using these resistors (10kohms) provide both
 states with a single push button switch.

0 When unpressed, the PIN state will read the GND
 state through the pull-down resistor. (the
 Resistor pulls the pin to GND when no i/p is
 present)

0 When pressed, the switch will read the VCC
 because it is the path of least resistance.

0 If VCC and GND are swapped in the diagram, the
 resistor is called a Pull-up resistor with reversal
 in logic levels.
Reading a switch
0 Open 3. LED_Switch folder.


0 Connect switch + resistor and LED + resistor circuits
 from the breadboard as shown.

0 Run Switch 1.pde on the arduino IDE and upload it
 onto the arduino.
Code
0 Switch is read using digital read. This will return either 1
  or 0. (HIGH / LOW).

0 This is stored in a variable.

0 LED is set to that variable.

0 So if switch is pressed, 1 is sensed and LED is set to 1.
0 When switch is released, 0 is sensed and LED turns off.

0 Voila!! LED is controlled by a switch.
Interrupts
0 Interrupts are signals that indicate to the
 microcontroller that a particular event has occurred.

0 Internal
   0 Divide by 0 interrupts
   0 Timer interrupts
   0 ADC interrupts

0 External
   0 Pin 2 & 3
External Interrupt
0 Pin 2 and 3 are set up for external interrupts.


0 Allow the arduino to continue doing tasks intstead of
 continuosly checking for external signal changes.

0 INT0 is on pin2 and INT1 is on pin3


0 Use attachinterrupt() to associate interrupts to a
 function.
attachInterrupt(interrupt, function, mode)

0 Interrupt: can be either 0 or 1 signifing which interrupt is
 being set up.

0 Function : is the name of the function to be called when
 the interrupt fires.

0 Mode:
  0 LOW to trigger the interrupt whenever the pin is low,
  0 CHANGE to trigger the interrupt whenever the pin changes
    value
  0 RISING to trigger when the pin goes from low to high,
  0 FALLING for when the pin goes from high to low.
The ISR
0 The interrupt service routine is the function that is
 called every time the interrupt fires.

0 Delay() and millis() are not supported inside an ISR.

0 Serial data received might be lost when the ISR
 returns.

0 All variables that get modified within the ISR must be
 volatile.
#include <avr/interrupt.h>

int ledPin = 12;
volatile int state = LOW;
void setup() {
  Serial.begin(9600);
  pinMode(12, OUTPUT);
  attachInterrupt(0, blink, FALLING);
}

void loop() {
  digitalWrite(ledPin,state);
}

void blink(){
  state = !state;
}
Remember
0 Make sure there are no loose connections on the
 breadboard.

0 Make sure you’ve gotten the upload successful
 message on the IDE.

0 Make sure switch GND, LED’s GND and arduino’s GND
 are one.

0 Don’t dismantle your circuits after completion.
Communication
0 Information is also transferred from arduino to
 computer by setting a pin HIGH or LOW in sucession
 to create a data waveform.

0 Each of this ‘1’s and ‘0’s are called as “bits”.


0 Because the data is transferred one after another on
 the same line, it is called serial transfer of data.

0 Kinda simillarish to morse code.
TX and RX pins
0 These pins light up when serial
  data is transmitted or received.

0 In the Arduino, the serial port
  goes through the FTDI chip and is
  converted to USB.

0 Pins 0 & 1 are the serial pins and
  serial data can be tapped from
  these pins.

0 Don’t use these pins for GPIO
  during serial transfers.
Baud rate
0 Baud rate is the unit of symbol rate.

0 A baud rate of 1 kBd = 1,000 Bd is synonymous to a
  symbol rate of 1,000 symbols per second.

0 In binary, a symbol is either a ‘1’ or ‘0’.

0 In serial communication systems, both the receiving
  machine and the transmitting system should be set to
  the same baud rate. (9600/11500 usually)
usage

0 In setup(){ } put serial.begin(9600);


0 In loop, use serial.println(data)


0 Open serial monitor to see data.
Serial Program
0 Open the folder 4. Serial and upload the arduino with
 the code.

0 The program prints numbers from 1-100 sequentially.

0 Use the serial monitor on the Arduino to see the
 stream.

0 Any program can open the COMx port associated with
 your arduino and read data transmitted by the
 arduino.
Question Time

Weitere ähnliche Inhalte

Was ist angesagt?

Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino MicrocontrollerShyam Mohan
 
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) - codewithgauriGaurav Pandey
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the ArduinoWingston
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduinoavikdhupar
 
Arduino Introduction (Blinking LED) Presentation (workshop #5)
Arduino  Introduction (Blinking LED)  Presentation (workshop #5)Arduino  Introduction (Blinking LED)  Presentation (workshop #5)
Arduino Introduction (Blinking LED) Presentation (workshop #5)UNCG University Libraries
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoYong Heui Cho
 
Automatic room temperature control
Automatic room temperature controlAutomatic room temperature control
Automatic room temperature controldebabratrath
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino ProgrammingJames Lewis
 
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3Abhishekvb
 
Iot based digital notice board with arduino
Iot based digital notice board with arduinoIot based digital notice board with arduino
Iot based digital notice board with arduinoNani Vasireddy
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controllerRkrishna Mishra
 
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 & DIYVishnu
 

Was ist angesagt? (20)

Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino Microcontroller
 
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
 
Arduino Uno Pin Description
Arduino Uno Pin DescriptionArduino Uno Pin Description
Arduino Uno Pin Description
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
 
Esp8266 basics
Esp8266 basicsEsp8266 basics
Esp8266 basics
 
Introduction of Arduino Uno
Introduction of Arduino UnoIntroduction of Arduino Uno
Introduction of Arduino Uno
 
Arduino Introduction (Blinking LED) Presentation (workshop #5)
Arduino  Introduction (Blinking LED)  Presentation (workshop #5)Arduino  Introduction (Blinking LED)  Presentation (workshop #5)
Arduino Introduction (Blinking LED) Presentation (workshop #5)
 
Arduino Functions
Arduino FunctionsArduino Functions
Arduino Functions
 
PPT ON Arduino
PPT ON Arduino PPT ON Arduino
PPT ON Arduino
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Automatic room temperature control
Automatic room temperature controlAutomatic room temperature control
Automatic room temperature control
 
Introduction to Arduino Programming
Introduction to Arduino ProgrammingIntroduction to Arduino Programming
Introduction to Arduino Programming
 
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
A Report on Bidirectional Visitor Counter using IR sensors and Arduino Uno R3
 
Arduino and robotics
Arduino and roboticsArduino and robotics
Arduino and robotics
 
Iot based digital notice board with arduino
Iot based digital notice board with arduinoIot based digital notice board with arduino
Iot based digital notice board with arduino
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 
Ardui no
Ardui no Ardui no
Ardui no
 
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
 

Ähnlich wie 02 General Purpose Input - Output on the Arduino

04 Arduino Peripheral Interfacing
04   Arduino Peripheral Interfacing04   Arduino Peripheral Interfacing
04 Arduino Peripheral InterfacingWingston
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptxHebaEng
 
Robotics Session day 1
Robotics Session day 1Robotics Session day 1
Robotics Session day 1Afzal Ahmad
 
03 analogue anrduino fundamentals
03   analogue anrduino fundamentals03   analogue anrduino fundamentals
03 analogue anrduino fundamentalsWingston
 
Arduino Hackday: Rebooting Computing
Arduino Hackday: Rebooting ComputingArduino Hackday: Rebooting Computing
Arduino Hackday: Rebooting Computingrebooting_computing
 
Bidirectional Visitor Counter with Automatic ON-OFF Switch2
Bidirectional Visitor Counter with Automatic ON-OFF Switch2Bidirectional Visitor Counter with Automatic ON-OFF Switch2
Bidirectional Visitor Counter with Automatic ON-OFF Switch2DIPAN GHOSH
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004DO!MAKERS
 
Wireless humidity and temperature monitoring system
Wireless humidity and temperature monitoring systemWireless humidity and temperature monitoring system
Wireless humidity and temperature monitoring systemSagar Srivastav
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshopJonah Marrs
 
Automation and Robotics 20ME51I_Week_2_Practicals.pdf
Automation and Robotics 20ME51I_Week_2_Practicals.pdfAutomation and Robotics 20ME51I_Week_2_Practicals.pdf
Automation and Robotics 20ME51I_Week_2_Practicals.pdfGandhibabu8
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptxMokete5
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorialsAnshu Pandey
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 

Ähnlich wie 02 General Purpose Input - Output on the Arduino (20)

04 Arduino Peripheral Interfacing
04   Arduino Peripheral Interfacing04   Arduino Peripheral Interfacing
04 Arduino Peripheral Interfacing
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Robotics Session day 1
Robotics Session day 1Robotics Session day 1
Robotics Session day 1
 
03 analogue anrduino fundamentals
03   analogue anrduino fundamentals03   analogue anrduino fundamentals
03 analogue anrduino fundamentals
 
ARDUINO (1).pdf
ARDUINO (1).pdfARDUINO (1).pdf
ARDUINO (1).pdf
 
Arduino Hackday: Rebooting Computing
Arduino Hackday: Rebooting ComputingArduino Hackday: Rebooting Computing
Arduino Hackday: Rebooting Computing
 
Rebooting Computing chalkwell
Rebooting Computing chalkwellRebooting Computing chalkwell
Rebooting Computing chalkwell
 
Bidirectional Visitor Counter with Automatic ON-OFF Switch2
Bidirectional Visitor Counter with Automatic ON-OFF Switch2Bidirectional Visitor Counter with Automatic ON-OFF Switch2
Bidirectional Visitor Counter with Automatic ON-OFF Switch2
 
Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004
 
Wireless humidity and temperature monitoring system
Wireless humidity and temperature monitoring systemWireless humidity and temperature monitoring system
Wireless humidity and temperature monitoring system
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Arduino workshop sensors
Arduino workshop sensorsArduino workshop sensors
Arduino workshop sensors
 
Automation and Robotics 20ME51I_Week_2_Practicals.pdf
Automation and Robotics 20ME51I_Week_2_Practicals.pdfAutomation and Robotics 20ME51I_Week_2_Practicals.pdf
Automation and Robotics 20ME51I_Week_2_Practicals.pdf
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptx
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 

Mehr von Wingston

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012Wingston
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - AndroidWingston
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - AndroidWingston
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - AndroidWingston
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - AndroidWingston
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - AndroidWingston
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with androidWingston
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - PointersWingston
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introductionWingston
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linuxWingston
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmtWingston
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for DrupalWingston
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for DrupalWingston
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in DrupalWingston
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring DrupalWingston
 
2 Installation of Drupal
2  Installation of Drupal2  Installation of Drupal
2 Installation of DrupalWingston
 

Mehr von Wingston (20)

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - Android
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with android
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring Drupal
 
2 Installation of Drupal
2  Installation of Drupal2  Installation of Drupal
2 Installation of Drupal
 

Kürzlich hochgeladen

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Kürzlich hochgeladen (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

02 General Purpose Input - Output on the Arduino

  • 1.
  • 2. Signals 0 Information is transferred in the digital/analogue world by signals. 0 Electrical Signals are given a logic equivalency to enable control and sensing from the physical universe. 0 1 == High == True == 3-5V 0 0 == Low == False == 0-2V 0 And thus the binary number system was born.
  • 3. Digital and Analogue information 0 Signals can be defined as any time varying quantity that can be said to represent information. 0 Digital signals, at any given point of time take up only one of a few discrete predefined states. 0 Analogue signals are not restricted to any particular state but continuously changes itself w.r.t. time.
  • 4. Hardware communication 0 Every electronic system will have two logic levels called VCC and GND. 0 Analogue signals in this can take any value between VCC and GND. 0 Digital Signals can only take the states of VCC and GND states. 0 Digital devices either control or respond to either VCC or GND.
  • 5. Ports 0 A microcontroller can digitally communicate with the outside world through Ports. 0 Every microcontroller has its own PORTs controlled by specific port registers. 0 Ports are a collection of PINS on the microcontroller. 0 Each pin can be controlled digitally by the microcontroller.
  • 6. PORTS on the arduino 0 The atmega328 has three ports 0 B (digital pin 8 to 13) 0 C (analog input pins) 0 D (digital pins 0 to 7) 0 Each Port has a 0 PORTx register that controls the value of the port. 0 DDRx register that controls the port from output/input mode.
  • 7. Digital Pins 0 Numbered 1 – 13 on the ardiono. 0 Can be set to Input/Output by pinMode(pin) function. 0 Can be set to output by digitalwrite(pin, state) function. 0 digitalread(pin) returns the state of the pin.
  • 8. Digital PIN as output 0 The pin is in a state of low impedance. 0 This means the pin can supply current to other circuits. (40mA) 0 Shorts or attempting to draw more current can damage the transistors on that pin (or fry the board). 0 Use resistors to limit current from the pins. (1- 10kohms)
  • 9. LEDs 0 Light Emitting diode. 0 Use R = (VS - VL) / I to calculate the resistor value to put in series. 0 Vs = 5V; VL = 2V (depends on color) 0 I = 40mA (max current required) 0 Do not connect LEDs in parallel!! 0 The longer end is VCC and the shorter end is GND.
  • 10. PIN13 on the Arduino 0 The arduino has an LED + resistor mounted on the board. 0 Open the program in folder 1. Blink in the arduino IDE. 0 Upload that program onto the board. 0 Watch blinky! 0 Can you make it blink faster? 0 Then slower?
  • 11. Connecting External LED 0 Open folder 2.LED Breadboard 0 Connect LEDs as shown in the circuit diagram. 0 Avoid connecting multiple LEDs to a single PIN. 0 If the PIN is HIGH the LED will light up.
  • 12.
  • 13. Digital Input 0 Digital Input can be sensed by all digital pins of the arduino. 0 Pins when set up as inputs are said to be in a High impedance state. 0 Which means they tend to draw very little current from the circuit they are sensing and that means that small changes in current are enough to change the state of the PIN. 0 If an input pin is left unconnected: 0 State may change randomly 0 Pin may capacitively couple & report the state of a nearby pin.
  • 14. Switches 0 Switches are mechanical devices that “switch” between VCC and GND states.
  • 15. Switching states 0 We need to switch between VCC and GND to use with digitalread(). 0 But, tactile switches can only open and close circuits. 0 In each of the cases, if switch is pressed, the PIN goes into a state, when released the PIN is disconnected or in a random state.
  • 16. Enter Pull-down resistors 0 Using these resistors (10kohms) provide both states with a single push button switch. 0 When unpressed, the PIN state will read the GND state through the pull-down resistor. (the Resistor pulls the pin to GND when no i/p is present) 0 When pressed, the switch will read the VCC because it is the path of least resistance. 0 If VCC and GND are swapped in the diagram, the resistor is called a Pull-up resistor with reversal in logic levels.
  • 17. Reading a switch 0 Open 3. LED_Switch folder. 0 Connect switch + resistor and LED + resistor circuits from the breadboard as shown. 0 Run Switch 1.pde on the arduino IDE and upload it onto the arduino.
  • 18.
  • 19. Code 0 Switch is read using digital read. This will return either 1 or 0. (HIGH / LOW). 0 This is stored in a variable. 0 LED is set to that variable. 0 So if switch is pressed, 1 is sensed and LED is set to 1. 0 When switch is released, 0 is sensed and LED turns off. 0 Voila!! LED is controlled by a switch.
  • 20. Interrupts 0 Interrupts are signals that indicate to the microcontroller that a particular event has occurred. 0 Internal 0 Divide by 0 interrupts 0 Timer interrupts 0 ADC interrupts 0 External 0 Pin 2 & 3
  • 21. External Interrupt 0 Pin 2 and 3 are set up for external interrupts. 0 Allow the arduino to continue doing tasks intstead of continuosly checking for external signal changes. 0 INT0 is on pin2 and INT1 is on pin3 0 Use attachinterrupt() to associate interrupts to a function.
  • 22. attachInterrupt(interrupt, function, mode) 0 Interrupt: can be either 0 or 1 signifing which interrupt is being set up. 0 Function : is the name of the function to be called when the interrupt fires. 0 Mode: 0 LOW to trigger the interrupt whenever the pin is low, 0 CHANGE to trigger the interrupt whenever the pin changes value 0 RISING to trigger when the pin goes from low to high, 0 FALLING for when the pin goes from high to low.
  • 23. The ISR 0 The interrupt service routine is the function that is called every time the interrupt fires. 0 Delay() and millis() are not supported inside an ISR. 0 Serial data received might be lost when the ISR returns. 0 All variables that get modified within the ISR must be volatile.
  • 24. #include <avr/interrupt.h> int ledPin = 12; volatile int state = LOW; void setup() { Serial.begin(9600); pinMode(12, OUTPUT); attachInterrupt(0, blink, FALLING); } void loop() { digitalWrite(ledPin,state); } void blink(){ state = !state; }
  • 25. Remember 0 Make sure there are no loose connections on the breadboard. 0 Make sure you’ve gotten the upload successful message on the IDE. 0 Make sure switch GND, LED’s GND and arduino’s GND are one. 0 Don’t dismantle your circuits after completion.
  • 26. Communication 0 Information is also transferred from arduino to computer by setting a pin HIGH or LOW in sucession to create a data waveform. 0 Each of this ‘1’s and ‘0’s are called as “bits”. 0 Because the data is transferred one after another on the same line, it is called serial transfer of data. 0 Kinda simillarish to morse code.
  • 27. TX and RX pins 0 These pins light up when serial data is transmitted or received. 0 In the Arduino, the serial port goes through the FTDI chip and is converted to USB. 0 Pins 0 & 1 are the serial pins and serial data can be tapped from these pins. 0 Don’t use these pins for GPIO during serial transfers.
  • 28. Baud rate 0 Baud rate is the unit of symbol rate. 0 A baud rate of 1 kBd = 1,000 Bd is synonymous to a symbol rate of 1,000 symbols per second. 0 In binary, a symbol is either a ‘1’ or ‘0’. 0 In serial communication systems, both the receiving machine and the transmitting system should be set to the same baud rate. (9600/11500 usually)
  • 29. usage 0 In setup(){ } put serial.begin(9600); 0 In loop, use serial.println(data) 0 Open serial monitor to see data.
  • 30. Serial Program 0 Open the folder 4. Serial and upload the arduino with the code. 0 The program prints numbers from 1-100 sequentially. 0 Use the serial monitor on the Arduino to see the stream. 0 Any program can open the COMx port associated with your arduino and read data transmitted by the arduino.