Article sections

    Purpose : Used for various digital functions on the IO lines.

    Supported MCUs:

    • PIC10F322
    • PIC16F15313

    Using In Your Projects: #include “PIC8Core/core/gpio.h”

    Dependencies: xc.h , stdint.h, PIC8Core.h

    **Refer to the PIC8-Core Device Pinout Diagrams for mapping of the PIN to Physical PORT PIN

    This is roughly, PORTA.0 is PIN0 – PORTA.1 is PIN1
    And so on – PORTA.7 is PIN7 – PORTB.0 would be PIN8

    Contains The Following Functions:

    • pinMode
    • digitalWrite
    • digitalRead
    • digitalToggle

    pinMode(pin,direction) – sets the direction of a pin making it either an input or output, also disables analog functions for the supplied pin. Note some pins are input only, refer to the device datasheet as to which one based on your device. *pinMode should be called first before any IO takes place on a given pin to setup the direction properly.

    pinMode(PIN0,INPUT) – Makes PIN0 an INPUT Pin
    pinMode(PIN1,OUTPUT) – Makes PIN1 an OUTPUT Pin

    digitalWrite(pin,value) – Writes a digital value to a PIN. Digital Value is either LOW, or HIGH. pinMode should be called first to set the given pin to the correct direction.

    digitalWrite(PIN1,HIGH) – Makes PIN1, HIGH – Digital Value 1
    digitalWrite(PIN2,LOW) – Makes PIN2, LOW – Digital Value 0

    digitalRead(pin) – Reads a pin setup as an input and returns the current digital input value of that pin.

    digitalRead(PIN0) – Reads PIN0 – returns 1 if HIGH, or 0 if LOW

    digitalToggle(pin) – Toggles the output of a given pin. If the current output is HIGH, calling toggle will change it to LOW. A LOW pin will become a HIGH pin.

    digitalToggle(PIN1) – Toggles PIN1

    in Modules

    Related Articles