Arduino FDP PPT PDF
Arduino FDP PPT PDF
is based on C/C++.
                                                                sensitive
                                           •	 Statements                are 
                                               commands  and  must 
                                               end  with  a  semicolon 
                                           •	 Comments  follow  a  // 
                                               or  begin  with  /*  and 
                                               end  with  */ 
See:  http://arduino.cc/en/Guide/Environment  for  more  information
is based on C/C++.
                                                                sensitive
                                           •	 Statements                are 
                                               commands  and  must 
                                               end  with  a  semicolon 
                                           •	 Comments  follow  a  // 
                                               or  begin  with  /*  and 
                                               end  with  */ 
See:  http://arduino.cc/en/Guide/Environment  for  more  information
                                        �	   Bootloader      is    the 
                                             hardware's  software 
                                             �	   bootloader        provides 
                                                  services      such      as 
                                                  firmware  upload  and 
                                                  serial monitoring. 
                                                  serial  monitoring.
                                        �	   Firmware  is  the  user's 
                                             software. 
                                        �	   Arduino  Tool  Chain 
                                             �	   Avrgcc 
                                             �    Avrg++ 
Presented  By:  Mr.  Shridhar  Dudam         �    Java  Virtual  Machine    28 
              Arduino  Programming  Environment
       � 
       �    loop() 
            loop()
� goto
� Syntax
� example
� Syntax
� Example
� Syntax
 �    Example
      Example
 �    HIGH  |  LOW 
 �    INPUT  |  OUTPUT  |  INPUT_PULLUP
 �    LED_BUILTIN 
 �    true  |  false 
 �    integer constants 
      integer    constants
 �    floating  point  constants 
     � 
     �    shiftIn() 
          shiftIn()
                         � 
                                             �    isControl() 
                                                  isControl()
     �    pulseIn()                          �    isDigit() 
                                             �    isGraph() 
�    Time                                    �    isLowerCase() 
     �     millis()                          �    isPrintable() 
                                             �    isPunct() 
      �  micros() 
                                             �    isSpace() 
      �  delay() 
                                             �    isUpperCase() 
      �  delayMicroseconds()                 �    isHexadecimalDigit() 
Presented  By:  Mr.  Shridhar  Dudam                                      45
              Functions  (3)
 �    Random  Numbers 
       �    randomSeed() 
       �    random() 
 �    Bits  and  Bytes 
       �
       �   lowByte() 
      �  highByte() 
� bitRead()
� bitWrite()
� bitSet()
� bitClear()
      �  bit()
Presented  By:  Mr.  Shridhar  Dudam    46
           Arduino  UNO:  GPIO
     �    Referred  to  as  0,1,2  ……  13 
�    6  analog  input  pins  can  be  used  as  digital  pins,
      �  LED:  13. 
Presented  By:  Mr.  Shridhar  Dudam                              47
              pinMode()
void setup() {
            pinMode(13, OUTPUT); 
       } 
void loop() {
          LCD Control 
          LCD  Control Lines 
                       Lines
                RS:  Select  Data  register  or  a  Command/Status
register.
�    Writing  to  LCD 
         �    Asserts  RS  high  to  select  DR 
         �    Writes  into  LCD  by  asserting  the  R/W  signal  low 
         �    Asserts  the  E  signal  high  and  then  low  (toggles)  to  latch  a  data  byte 
              or  an  instruction 
�    Reading  from  LCD 
         �
         �    Asserts  RS  low  to  select  IR 
         �    Reads  from  LCD  by  asserting  the  R/W  signal  high 
         �    Asserts  the  E  signal  high  and  then  low  (toggles)  to  latch  a  data  byte 
              or  an  instruction 
              LCD  Interface  Modes
 �	   8  bit  mode 
       �	   Uses  all  8  data  lines  DB0DB7 
       �	   Data  transferred  to  LCD  in  byte  units 
       �	   Interface  requires  10  (sometimes  11)  I/O  pins  of 
       �
       �	   microcontroller  (DB0DB7, 
                                (DB0DB7 , RS, 
                                            RS , E)  (sometimes  R/W) 
 �	   4bit  mode 
       �	   4bit  (nibble)  data  transfer 
       �	   Each  byte  transfer  is  done  in  two  steps:  high  order 
            nibble,  then  low  order  nibble 
       �	   Interface  requires  only  6  (sometimes  7)  I/O  pins  of 
            microcontroller  (DD4DB7,  RS,  E) 
Presented  By:  Mr.  Shridhar  Dudam                                   58
              LCD  Interfacing  Diagram
 �    lcd.begin(numCols,  numRows); 
 �    lcd.setCursor(colNumber,  rowNumber);
 �    lcd.print(Data  to  be  displayed); 
 �    lcd.clear();
      lcd.clear(); 
 �    lcd.blink();  &  lcd.noBlink(); 
 �    lcd.display();  &  lcd.noDisplay(); 
 �    lcd.scrollDisplayLeft(); 
 �    lcd.scrollDisplayRight(); 
 �    lcd.createChar(charNumber,  charArray);
delay(500);
delay(500); }
                                   �	   Vertically  arranged 
                                        keys  are  called 
                                        scanning  line  or 
                                        columns 
                                   �	   horizontally 
                                        arranged keys are
                                        called return line
                                        or rows
 �	   char  keymap[numRows][numCols]=  { 
      {'1',  '2',  '3'},  {'4',  '5',  '6'},  {'7',  '8',  '9'}  }; 
 �	   byte  rowPins[numRows]  =  {8,  9,  10}; 
 �	   byte  colPins[numCols]=  {11,  12,  13}; 
 �	   Keypad myKeypad= 
      Keypad      myKeypad=
      Keypad(makeKeymap(keymap),  rowPins, 
      colPins,  numRows,  numCols); 
 �	   char  keypressed  =  myKeypad.getKey(); 
 �	     In  Setup  function 
   �	      Set  up  the  LCD's  number  of  columns  and  rows. 
   �	      Print  Message  “Keypad  Interface”  on  first  line  of  LCD 
   �	      Set  Cursor  of  LCD  to  2nd  line  first  column. 
   �
   �	      Print  Message  “Key 
                             “Key  Pressed 
                                   Pressed” ” on  second  line  of  LCD 
 �	     In  Loop  function 
      �	   Declare  the  Char  Variable  to  hold  the  key  value 
      �	   Get  the  key  pressed  value  using  getKey()  function 
      �	   Display  the  value  of  Key  on  LCD  it  valid  key  is
pressed.
Serial Parallel
Receiver Receiver
1 bit
1 word
          Transmitter         Transmitter
        Data  Transmission  (2)
Serial Parallel
Transmission 
Transmission         Single bit 
                     Single  bit                8  bits 
                                                8  bits (8 
                                                         (8 data 
                                                            data lines) 
                                                                  lines)
Amount                                          Transmitter  &  Receiver
�    Synchronous 
      �  Synchronous  Peripheral  Interface  (SPI) 
�    Asynchronous 
      �  Serial  Communication  Interface  (SCI) 
        Serial  Communication  Protocol
Bit Types
�    Start  Bit 
         �    Signals  the  transmission  of  a  word. 
         �    Transition  from  “1”  to  “0”.  (“Marktospace”)
                                 t ransmitt ed.
         �    Sender  and  receiver  have  to  agree  in  the  number  of 
              data  bits.  (Usually  8  or  9) 
         �    Least  significant  bit  is  sent  first. 
         �    Can  be  low  or  high. 
�    Stop  Bits 
         �    Bit  at  the  end  of  a  data  word. 
         �    Bit  set  to  high  “1”. 
         �    Indicates  the  end  of  a  word. 
          Bit  Types
�    Parity  bit  – 
         �    Works  as  an  error  check. 
         �	   There  are  two  types:  odd  and  even 
                �    Even:  if  number  of  1’s  in  the  data  word  is  even. 
                �    Odd:  if  number  of  1’s  in  the  data  word  is  odd. 
         �    Bit  after  the  data  bits  and  before  the  stop  bit.
         �
         �	   Can  prevent  single  noise  signal, 
                                              signal , but  does  not  recognize 
              when  two  bits  are  altered  by  noise. 
         �    Used  to  prevent  noise. 
              ATmega328P:  USART  features
 �	   In  Setup  function 
       �    Initialize  the  serial  port  with  desired  baud  rate 
            (e.g.  9600) 
       �	   Transmit  the  initial  messages 
 �	   In  Loop  function 
       �	   Declare  the  Variable  with  data  type  integer  to  hold 
            the  received  data 
       �	   Check  for  any  data  is  received  on  serial  port 
       �	   If  yes  read  the  data  into  variable  and  retransmit 
            the  data  on  serial  port 
Presented  By:  Mr.  Shridhar  Dudam                                    79
              Serial  Communication:  loopback
 void  setup()  { 
        Serial.begin(9600);  //  initialize  serial  ports: 
        Serial.println("Serial  Communication  Demo"); 
        Serial.println("Please  send  data"); 
 }} 
   void  loop()  {
if (Serial.available()) {
Serial.write(inByte);
} }
To ADC
   1.  Thermistor 
   2.  Thermocouple 
   3.  RTD 
   4.  LM35 
   ….  Much  more 
                                        Temperature  Sensor 
                                        �	 Popularly  Used 
                                        �	 No  Signal  Condition  Circuit 
                                           is  required 
                                        �	 Output  in  terms  of  voltage
                                             �	 10mv/degree 
Presented  By:  Mr.  Shridhar  Dudam                                         90
              LM35  Interfacing  to  Arduino
#include <LiquidCrystal.h>
 void  setup()  { 
    lcd.begin(16,  2);  //  set  up  the  LCD's  no.  of  columns  and  rows: 
    lcd.setCursor(0,  2); 
    lcd.print("Temprature:  ");  //  Print  a  message  to  the  LCD. 
 } 
 void  loop() 
 { 
    float  temp; 
     //Read  Temperature  Sensor 
    temp  = = (5.00  * 
                     * analogRead(A4)  * 
                                       * 100)  /  1023.0;
                                                  1023.0; 
    lcd.setCursor(11,  1);
lcd.print(temp);
delay(500);
                                                                  •	 Command: 
                                                                     analogWrite(pin,value) 
                                                                  •	 value  is duty cycle: 
                                                                     between  0  and  255 
                                                                                      255
                                                                  •	 Examples: 
                                                                     analogWrite(9,  128) 
                                                                     for  a  50%  duty cycle 
analogWrite(11, 64)
 void  setup()  { 
    pinMode(10,  OUTPUT);  //  initialize  pin as  an output. 
   } 
 void  loop()  { 
      for(int  x  =  0;  x  <=  255;  x=x+10)  { 
         analog Write( 10,  x); 
         analogWrite(10,        x); 
         delay(50);
analogWrite(10, x);
delay(50);
                                                                  •	 Command: 
                                                                     analogWrite(pin,value) 
                                                                  •	 value  is duty cycle: 
                                                                     between  0  and  255 
                                                                                      255
                                                                  •	 Examples: 
                                                                     analogWrite(9,  128) 
                                                                     for  a  50%  duty cycle 
analogWrite(11, 64)
 �    Use  of Accelerometer 
       �    To  detect  when  something  starts  or  stop  moving. 
       �    To  detect  how  something  is  oriented  with  respect 
            to  Earths  Surface
void setup() {
         Serial.begin(9600); 
         Serial.begin   (9600);  } }
       void  loop()  { 
        Serial.print(analogRead(xpin));  Serial.print("t"); 
        Serial.print(analogRead(ypin));  Serial.print("t"); 
        Serial.print(analogRead(zpin));  Serial.print("t"); 
        Serial.println(); 
        delay(100);  } 
Presented  By:  Mr.  Shridhar  Dudam                           106
              DC  motor  Interface
                                        Motor Driver
         Arduino                                       DC Motor
                                          Circuit
void setup() {
pinMode(motor1Pin1, OUTPUT); // set all the other pins you're using as outputs:
pinMode(motor1Pin2, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, HIGH); // set enablePin high so that motor can turn on:
void loop() {
delay(500);
delay(500);
delay(500);
                      l
                   R ρA =
  Wheatstone  Bridge
 VEX V0
                          R2        R3
          What  is  a  Load  Cell?
� Force Gauges
� Torque Gauges
                         Signal
      Load Cell        Conditioning         ADC           Microcontroller
                         Circuit
 Load  Cells:  Types
                 Button
                                 Canister
S Type
         Shear            Beam
             Load  Cell  Signal  Conditioner
                                         HX711
                                                                 Arduino
            Load Cell                   Load Cell
                                                                  UNO
                                        Amplifier
 �	   An  LVDT  consists  of 
      three  coils,  one  primary 
      and  two  secondary.  A 
      movable  magnetic  core 
      is  placed  as  shown  in 
      the 
      th e fi
           figure. 
             gure.
 �	   The  output  of  the  LVDT 
      is  proportional  to  the 
      position  of  the  core. 
!!!!