Digital I/O

This GR-CITRUS sketch reference library is used to input/output a digital signal (HIGH or LOW).

pinMode

Description
Configures the specified pin to behave either as an input or an output.
Syntax
pinMode(uint8_t pin, uint8_t mode)
Parameters
pin: The number of the pin whose mode you wish to set
mode:
   INPUT
   OUTPUT
   INPUT_PULLUP (pull up and input)
   OUTPUT_OPENDRAIN (open drain output)
Returns
None

digitalWrite

Description
Write a HIGH or a LOW value to a digital pin.
Syntax
digitalWrite(uint8_t pin, uint8_t value)
Parameters
pin: The pin number
value: HIGH or LOW
Returns
None

digitalRead

Description
Reads the value from a specified digital pin, either HIGH or LOW.
Syntax
digitaRead(uint8_t pin)
Parameters
pin: The number of the digital pin you want to read
Returns
HIGH or LOW

Sample Program

This sample makes an LED blink.


#include <Arduino.h>
#define INTERVAL 100
 
void setup()
{
    pinMode(PIN_LED0, OUTPUT);
}
 
void loop()
{
    static led = 1;
    digitalWrite(PIN_LED0, led);
    led = !led;
    delay(100);
}