Announcement

Collapse
No announcement yet.

Arduino - Digital Input Board

Collapse
X
Collapse

  • Arduino - Digital Input Board

    PES-2602 is an easy-to-use 4-port Input Expansion Board for Arduino Uno and Mega, which allows Arduino to monitor state of DC electric device. In addition, it can monitor NPN, PNP and dry contact(relay).
    Library and example for the 4-port input expansion board are part of of PhpocExpansion library for Arduino. The library reference is available here.

    This tutorial shows how to use 4-port input expansion board with an example of PhpocExpansion library for Arduino.


    Hardware Required



    Wiring
    • Stack PHPoC Shield or PHPoC WiFi Shield on Arduino
    • Stack input expansion board PES-2602 on PHPoC Shield or PHPoC WiFi Shield
    • (optional) Connect the terminal block of input expansion board to a DC electric device.




    Since input expansion board has four input port, it can monitor state of four devices simultaneously. The above images show only one device for illustration.

    Install Arduino IDE

    If you have not install Arduino IDE yet, please download and install Arduino IDE .





    Install Library
    • Run Arduino IDE.
    • Navigate to Sketch > Include Library > Manage Libraries

    • Search "Phpoc Expansion" on search bar of the Library Manager.

    • Select the PhpocExpansion library and press the [Install] button.

    • Restart Arduino IDE for the next step.



    Source Code
    • Connect Arduino to PC via usb cable
    • Open Arduino IDE
    • Open "ExpansionPhotoInput" example
    • Compile the example code and uploads to Arduino by clicking "Upload" button on Arduino IDE
    • Open "Serial Monitor" tool on Arduino IDE to see the output log:
    • If you connected a DC electric device to input expansion board, try to turn on/off device. And then see LED on input expansion board and log on Serial Monitor.
    • If you does not connect a DC electric device to input expansion board, try to connect GND pin and 5v pin to GND pin and DI0 pin, respectively. And then see stgatus LED on input expansion board and log on Serial Monitor.

      (on/off states depends on the input value)

    Code Explanation

    At the beginning
    we need to create and four input object:
    Code:
    ExpansionPhotoInput in0(expansionId, 0);
    ExpansionPhotoInput in1(expansionId, 1);
    ExpansionPhotoInput in2(expansionId, 2);
    ExpansionPhotoInput in3(expansionId, 3);
    Where expansionId is address of expansion board that are set via DIP switch on expansion board. By using the different expansionId, we can stack multiple expansion board on a single Arduino Uno or Mega.
    You can change it and map it to the below to know the value.





    Note that: 4-port input expansion board is one of the expansion boards. List of expansion for arduino is available here

    In setup() function
    • Phpoc.begin() and Expansion.begin() functions must be used to initial PHPoC [WiFi] Shield and expansion board, repectively.
    • Serial.println(in0.getName()) function is used optionally to get name of expansion board and print it to serial.
    • There are some functions has been commented.
      Code:
      	//in0.setDelay(900);
      	//in1.setDelay(1000);
      	//in2.setDelay(1100);
      	//in3.setDelay(1200);
      These functions are optional and used to set the debounce time. Refer to PHPoC Shield Expansion Library Reference for more information about these functions.


    In loop() function
    There are some functions are used.
    • in0.isOn(): check whether the state of input port is on or not.
    • in0.isOff(): check whether the state of input port is off or not.



    See Also


    References
      Posting comments is disabled.

    Categories

    Collapse

    Latest Articles

    Collapse

    • Arduino - RS-485 Expansion Board
      support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 03:45 PM
    • Arduino - RS-422 Expansion Board
      support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 03:44 PM
    • Arduino - RS-232 Expansion Board
      support
      PES-2606 is an easy-to-use RS-232 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS-232.
      Especially, Arduino does NOT use UART pins to communicate with RS-232 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS-232 expansion boards (up to 14) without using Arduino UART pins.

      Library and example for the RS-232 expansion board...
      11-13-2018, 03:43 PM
    • Arduino - Stepper Motor Controller
      support
      PES-2605 is an easy-to-use stepper motor controller for Arduino Uno and Mega, which uses micro-stepping method to precisely control stepper motor.
      Library and example for the stepper motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the step motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 03:41 PM
    • Arduino - DC Motor Controller
      support
      PES-2604 is an easy-to-use DC motor controller for Arduino Uno and Mega.
      Library and example for the DC motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the DC motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 03:40 PM
    • Arduino - Digital Input Board
      support
      PES-2602 is an easy-to-use 4-port Input Expansion Board for Arduino Uno and Mega, which allows Arduino to monitor state of DC electric device. In addition, it can monitor NPN, PNP and dry contact(relay).
      Library and example for the 4-port input expansion board are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use 4-port input expansion board with an example of PhpocExpansion library for Arduino.

      ...
      11-13-2018, 03:39 PM
    Working...
    X