Skip to content
gicking edited this page Feb 6, 2018 · 3 revisions

back to Command Reference / Digital-IO

Description

Set the output state of an I/O pin to low (=0V=GND).

If the pin has been configured as an OUTPUT via pinMode() or portMode(), this command drives the pin voltage to low.

Notes:

  • after reset all I/O pins are configured as INPUT
  • if a pin is configured as INPUT*, pinLow() has no effect.

Inclusion

  • defined in gpio.h
  • auto-loaded in main_general.h
  • no #define required

Syntax

pinLow(pPort, pin)

Parameters

  • input:

    • pPort: address of port to set, e.g. &PORT_A
    • pin: pin you wish to set (0..7)
  • output:

    • none

Returns

  • Nothing

Example Code

The below code makes pin PD0 (=LED on STM8S Discovery) an OUTPUT and toggles it HIGH and LOW with 1s delay.

#include "main_general.h"   // board-independent main

void setup()
{
  pinMode(&PORT_D, 0, OUTPUT);    // set PD0 as output
}

void loop()
{
  pinHigh(&PORT_D, 0);            // set PD0 on
  delay(1000);                    // wait 1s
  pinLow(&PORT_D, 0);             // set PD0 off
  delay(1000);                    // wait 1s
}

Relevant Tutorial

Notes and Warnings

To avoid damage

  • do not expose I/Os to voltages outside [-0.3V; Vdd+0.3V], else limit injection currents to the specificied limits
  • for OUTPUT pins assert that sink and source currents are below the specificied limits
  • do not directly connect two OUTPUT pins. If e.g. half-duplex is required, use a pull-up and OUTPUT_OPENDRAIN, instead

See also

Clone this wiki locally